Giter Club home page Giter Club logo

dash-live's Introduction

Simulated MPEG DASH service

A Python application that provides an endpoint for multiple MPEG DASH manifests. These manifests are dynamically generated from templates of various vendor's packaging output.

The principal use for this service is to test live DASH streams using non-live, rights cleared material. There are a large number of configuration options that can be applied to these streams and manifests, giving millions of different combinations.

Installation

Python 3.11 or greater is required by this application.

A .env needs to be created that contains

FLASK_SECRET_KEY='arandomstring'
FLASK_DASH__CSRF_SECRET='arandomstring'
FLASK_DASH__DEFAULT_ADMIN_USERNAME='admin'
FLASK_DASH__DEFAULT_ADMIN_PASSWORD='secret'
FLASK_DASH__ALLOWED_DOMAINS='*'

The name of the .env file can be changed by setting the environment variable DASHLIVE_SETTINGS to the filename to use to load the above settings.

The FLASK_SECRET_KEY, FLASK_DASH__CSRF_SECRET variables need to contain a randomly generated block of ascii characters. There is a gen_settings.py script that can be used to auto-generate the .env file.

The FLASK_DASH__ALLOWED_DOMAINS setting is optional. It controls the HTTP response header Access-Control-Allow-Origin that is used to control which origins are allowed to make HTTP requests from JavaScript to this server.

If the FLASK_DASH__ALLOWED_DOMAINS is missing, a default list of domains that supports common JavaScript DASH libraries will be used. An allowed_domains value of "*" tells the server to allow any JavaScript request from any domain.

The FLASK_DASH__DEFAULT_ADMIN_PASSWORD setting controls the default password to use for the admin user account when creating a new blank database.

Running the development server directly on the host machine

Create a Python virtual environment and install the dependencies:

python3 -m venv virtenv
. ./virtenv/bin/activate
pip install -r requirements.txt

The CSS files need to be compiled:

python -m lesscpy static/css -o static/css/

To start the server:

python -m flask --app dashlive.server.app run --host=0.0.0.0 --debug

It will start an HTTP server on port 5000

See docs/deploy.md for more information on the various options for deploying this service.

Adding User Accounts

By default, the server will create a new admin account using the username and password values defined in .env. You will need to use that username and password to log into the server and then change the password. From the users page can then be used to add additional users to the system.

See docs/users.md for more information about the user authentication system.

Streams

Each stream entry represents a playable audio/video stream. Each stream must have at least one video and one audio MP4 file. Typically each stream will have multiple video files associated with it, one for each available bitrate.

See docs/streams for more information about DASH streams.

See docs/media for more information about media file requirements and how to upload and download files from the server.

Viewing Media Details

Once a media file has been indexed, clicking on the name of one of the uploaded files will show a page listing the information extracted from the media file. Clicking on the Number of Segments link will show information about each segment.

Clicking on the link for one of those segments will show every MP4 atom that has been parsed from the file.

DASH Stream Validation

The /validate page allows the checking the validity of a DASH stream. It will inspect the contents of the DASH manifest and all the requested segments in the stream. If it finds any values that don't adhere to the DASH specification, they will be logged in the output summary.

See docs/validate for more information about the DASH validator.

Migrating from Python 2 version

This version is incompatible with the previous Python 2 version. Migrating the Python 2 version requires complete re-creation of the database and re-uploading media files.

The old python-2.7 branch of this application has a download-db.py script that can be used to extract all of the data from the old server.

Using a checkout of the python-2.7 branch to download the data from a running Python 2 version of this app into a tmp directory:

python2 download-db.py --host http://localhost:9080/ tmp

The dashlive.upload script from this version can be used to take this extracted data and upload it to the new server. This process should preserve all of the information between versions. The Timing reference property of each uploaded stream needs to be set before the streams are playable.

Using a checkout of the main branch to upload this data to a new server:

python3 -m dashlive.upload --username=admin --password=mysecret \
    --host http://localhost:5000/ tmp/downloaded.json

Testing

See docs/testing for information about running the unit tests and coverage reports. At the time of writing, there is just under 80% code test coverage.

statements missing excluded branches partial coverage
12484 2342 94 5216 741 79%

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

dash-live's People

Contributors

asrashley avatar dependabot[bot] avatar

Stargazers

D's avatar

Watchers

James Cloos avatar  avatar  avatar

dash-live's Issues

video HTML page produces Internal Server Error

commit 2668bee added a "pure" keyword argument to the toJSON() function, but this was not checked against the /video page. When trying to navigate to the /video page, an internal server error is generated:

Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/home/dash/dash-live/src/views.py", line 1160, in get
    self.response.write(template.render(context))
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/lib/jinja2-2.6/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/dash/dash-live/src/../templates/video.html", line 1, in top-level template code
    {% extends 'layout.html' %}
TypeError: toJSON() got an unexpected keyword argument 'pure'

Migrate from passlib to pwdlib

For years, the de-facto standard to hash passwords was passlib. Unfortunately, it has not been very active recently and its maintenance status is under question. Starting Python 3.13, passlib won't work anymore.

The library pwdlib looks like a good replacement candidate. However it's not clear if an existing user database could be migrated to use this library.

Validator is requiring init segments for all media types

The DASH validator is asserting that every AdaptationSet has an init segment. Some track types (e.g. image or text) don't require initialization segments.

The validator should not generate an error for adaptation sets without an init segment if it is not required by the codec.

Update to v3 of Flask

The current version of Flask is v3.0.3, but this code uses v2.3.3

To be able to update Flask will also require other libraries to be updated

    The user requested Flask==3.0.3
    flask-socketio 5.3.6 depends on Flask>=0.9
    flask-sqlalchemy 3.0.3 depends on Flask>=2.2
    flask-jwt-extended 4.5.2 depends on Flask<3.0 and >=2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.