Skip to main content

lxml based parser for DASH manifests (mpd files)

Project description

mpd-parser

Installation

$ python -m pip install mpd-parser

Note: mpd-parser requires Python 3.10 or newer.

Usage

Importing

from mpd_parser.parser import Parser

parse from string

with open("path/to/file.mpd", mode="r") as manifest_file:
    mpd_string = manifest_file.read()
    parsed_mpd = Parser.from_string(mpd_string)

parse from file

input_file = "path/to/file.mpd"
mpd = Parser.from_file(input_file)

convert back to string

mpd_as_xml_string = Parser.to_string(parsed_mpd)

Overview

A utility to parse mpeg dash mpd files quickly This package is heavily inspired by mpegdash package the main difference is that I choose to relay on lxml for parsing, and not the standard xml library.

The decision to implement it with lxml is for two reasons:

  1. lxml is faster then minidom
  2. lxml mimics the ElementTree API which is a more pythonic approach to XMLs

mpegdash package has two distinct advantages over this package:

  1. it does not require third party libraries.
  2. it uses the classic DOM approach to parsing XML files. it is a well known standard.

Benchmarks

You can run the benchmarks using the scripts in the benchmarks/ directory.

$ python benchmarks/bench_mpd_parser.py --file manifests/test_manifest_1mb.mpd
$ python benchmarks/bench_mpegdash.py --file manifests/test_manifest_1mb.mpd

Results

On a 1MB MPD file with 6,200 representations:

  • mpd-parser: ~7 ms / parse
  • mpegdash: ~174 ms / parse

(mpd-parser is ~24x faster than mpegdash on this payload).

Example manifests

Taken from https://ottverse.com/free-mpeg-dash-mpd-manifest-example-test-urls/ These are what I used to test and benchmark the package.

Missing unit-tests

  1. tags
  2. attribute parsers
  3. full manifest testing

Contributing

TBA

Build locally

python -m build

Run pylint locally

I try to keep the pylint score above 9.

python -m pylint ./mpd_parser/

TODO

  1. finish working on periods and sub tags
    1. periods
    2. adapt-sets
    3. segment bases
    4. segment lists
    5. segment templates
    6. asset ids
    7. event streams
    8. subsets
  2. create package locally
  3. test it
  4. complete readme
    1. installation
    2. usage
    3. Benchmarks
    4. contributing
  5. push to github
  6. push package to pypi
  7. add github actions
    1. pylint
    2. pytest
    3. build package
    4. push package
  8. complete unit-tests
  9. refactor tags to multiple files
  10. Parsing:
    1. parsing from string
    2. parsing from file
    3. parsing from URL
  11. save mpd object:
    1. object to string
    2. object to file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpd_parser-0.2.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpd_parser-0.2.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file mpd_parser-0.2.0.tar.gz.

File metadata

  • Download URL: mpd_parser-0.2.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for mpd_parser-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bdecdb77f13298e983d5114791a3b4d63cf60cd1160acfc03b7e343e4cd44752
MD5 2e3292b8146b49c3df05849b1a1ffdff
BLAKE2b-256 247f80400884490f9f8efb755125126356cee586f94c2ef4095b820667a08e78

See more details on using hashes here.

File details

Details for the file mpd_parser-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mpd_parser-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for mpd_parser-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ab3990dff1b287a4934595c364f5b666e7f9e625230783842bc83ca3a868d1e
MD5 70905d50ca9ccf00c2ab86e2c73cd389
BLAKE2b-256 c23071584f569bacc674c0937cee348f5571126fdd01bb2e91449737f82d7dfb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page