Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 6b78a4d46f0ece05b9c94d2afacb5a21864ecf9a 0 parents
Antoine Bertin authored
32 .gitignore
@@ -0,0 +1,32 @@
+*.py[cod]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+lib
+lib64
+__pycache__
+
+# Installer logs
+pip-log.txt
+
+# PyDev
+.project
+.pydevproject
+.settings
+
+# Sphinx
+docs/_build
+
+# Enzyme test folders
+enzyme/tests/test_*/
+
3  .gitmodules
@@ -0,0 +1,3 @@
+[submodule "docs/_themes"]
+ path = docs/_themes
+ url = git://github.com/Diaoul/diaoul-sphinx-themes.git
7 .travis.yml
@@ -0,0 +1,7 @@
+language: python
+python:
+ - 2.7
+ - 3.3
+script: python setup.py test
+notifications:
+ irc: "irc.freenode.org#enzyme"
8 HISTORY.rst
@@ -0,0 +1,8 @@
+News
+====
+
+0.3
+---
+**release date:** 2013-05-18
+
+* Complete refactoring, for the old enzyme see https://github.com/Diaoul/enzyme-old
13 LICENSE
@@ -0,0 +1,13 @@
+Copyright 2013 Antoine Bertin
+
+ 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.
1  MANIFEST.in
@@ -0,0 +1 @@
+include LICENSE README.rst HISTORY.rst
7 README.rst
@@ -0,0 +1,7 @@
+Enzyme: video metadata parser
+=============================
+
+.. image:: https://travis-ci.org/Diaoul/enzyme.png?branch=master
+ :target: https://travis-ci.org/Diaoul/enzyme
+
+Enzyme is an `Apache2 Licensed <http://opensource.org/licenses/Apache-2.0>`_ video metadata parser library written in Python.
177 docs/Makefile
@@ -0,0 +1,177 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ebmc.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ebmc.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/ebmc"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ebmc"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
4 docs/_templates/sidebar-intro.html
@@ -0,0 +1,4 @@
+<h3>Enzyme</h3>
+<p>
+ Enzyme is a video metadata parser library written in Python.
+</p>
1  docs/_themes
@@ -0,0 +1 @@
+Subproject commit 24aa9748e450444522b8af35e4580c8f6f72b405
50 docs/api/mkv.rst
@@ -0,0 +1,50 @@
+MKV
+===
+.. module:: enzyme.mkv
+
+`Matroska Video <http://en.wikipedia.org/wiki/Matroska>`_ files use the :ref:`ebml` structure.
+
+
+Track types
+~~~~~~~~~~~
+.. data:: VIDEO_TRACK
+
+ Video track type
+
+.. data:: AUDIO_TRACK
+
+ Audio track type
+
+.. data:: SUBTITLE_TRACK
+
+ Subtitle track type
+
+
+Main interface
+~~~~~~~~~~~~~~
+.. autoclass:: MKV
+ :members:
+
+.. autoclass:: Info
+ :members:
+
+.. autoclass:: Track
+ :members:
+
+.. autoclass:: VideoTrack
+ :members:
+
+.. autoclass:: AudioTrack
+ :members:
+
+.. autoclass:: SubtitleTrack
+ :members:
+
+.. autoclass:: Tag
+ :members:
+
+.. autoclass:: SimpleTag
+ :members:
+
+.. autoclass:: Chapter
+ :members:
92 docs/api/parsers.rst
@@ -0,0 +1,92 @@
+Parsers
+=======
+A parser extract structured information as a tree from a container as a file-like object.
+It does the type conversion when explicit but does not interpret anything else.
+Parsers can raise a :class:`~enzyme.exceptions.ParserError`.
+
+.. _ebml:
+
+EBML
+----
+.. module:: enzyme.parsers.ebml
+
+`EBML (Extensible Binary Meta Language) <http://matroska.org/technical/specs/index.html>`_ is used
+by `Matroska <http://en.wikipedia.org/wiki/Matroska>`_ and `WebM <http://en.wikipedia.org/wiki/WebM>`_.
+
+Element types
+~~~~~~~~~~~~~
+.. data:: INTEGER
+
+ Signed integer element type
+
+.. data:: UINTEGER
+
+ Unsigned integer element type
+
+.. data:: FLOAT
+
+ Float element type
+
+.. data:: STRING
+
+ ASCII-encoded string element type
+
+.. data:: UNICODE
+
+ UTF-8-encoded string element type
+
+.. data:: DATE
+
+ Date element type
+
+.. data:: BINARY
+
+ Binary element type
+
+.. data:: MASTER
+
+ Container element type
+
+Main interface
+~~~~~~~~~~~~~~
+.. data:: SPEC_TYPES
+
+ :ref:`Specification <specs>` types to `Element types`_ mapping
+
+.. data:: READERS
+
+ `Element types`_ to reader functions mapping. See `Readers`_
+
+ You can override a reader to use one of your choice here::
+
+ >>> def my_binary_reader(stream, size):
+ ... data = stream.read(size)
+ ... return data
+ >>> READERS[BINARY] = my_binary_reader
+
+.. autoclass:: Element
+ :members:
+
+.. autoclass:: MasterElement
+ :members:
+
+.. autofunction:: parse
+
+.. autofunction:: parse_element
+
+.. autofunction:: get_matroska_specs
+
+Readers
+~~~~~~~
+.. automodule:: enzyme.parsers.ebml.readers
+ :members:
+
+.. _specs:
+
+Specifications
+~~~~~~~~~~~~~~
+The XML specification for Matroska can be found `here <http://matroska.svn.sourceforge.net/viewvc/matroska/trunk/foundation_src/spectool/specdata.xml>`_.
+It is included with enzyme and can be converted to the appropriate format with :func:`~enzyme.parsers.ebml.get_matroska_specs`.
+
+The appropriate format of the `specs` parameter for :func:`~enzyme.parsers.ebml.parse`, :func:`~enzyme.parsers.ebml.parse_element`
+and :meth:`~enzyme.parsers.ebml.MasterElement.load` is ``{id: (type, name, level)}``
268 docs/conf.py
@@ -0,0 +1,268 @@
+# -*- coding: utf-8 -*-
+#
+# enzyme documentation build configuration file, created by
+# sphinx-quickstart on Fri May 10 01:11:03 2013.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('..'))
+sys.path.append(os.path.abspath('_themes'))
+import enzyme
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = enzyme.__title__
+copyright = ' '.join(enzyme.__copyright__.split()[1:])
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = enzyme.__version__
+# The full version, including alpha/beta/rc tags.
+release = enzyme.__version__
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'diaoul'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+html_theme_options = {'github_user': 'Diaoul',
+ 'github_repo': 'enzyme',
+ 'github_branch': 'master',
+ 'fork_me': 1,
+ 'flattr': 0,
+ 'gittip': 'Diaoul',
+ 'pypi_downloads': 1,
+ 'pypi_version': 0,
+ 'travis': 0,
+ 'coveralls': 0}
+
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = ['_themes']
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+html_sidebars = {
+ 'index': ['sidebar-intro.html', 'sidebar-star.html', 'sidebar-pypi.html', 'sidebar-donate.html',
+ 'sourcelink.html', 'searchbox.html'],
+ '**': ['sidebar-intro.html', 'sidebar-star.html', 'sidebar-pypi.html', 'sidebar-donate.html',
+ 'localtoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html']
+}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'enzymedoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'enzyme.tex', u'enzyme Documentation',
+ u'Antoine Bertin', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'enzyme', u'enzyme Documentation',
+ [u'Antoine Bertin'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'enzyme', u'enzyme Documentation',
+ u'Antoine Bertin', 'enzyme', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+
+# -- Options for autodoc -------------------------------------------------------
+autodoc_member_order = 'bysource'
37 docs/index.rst
@@ -0,0 +1,37 @@
+.. enzyme documentation master file, created by
+ sphinx-quickstart on Fri May 10 01:11:03 2013.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Enzyme
+======
+Release v\ |version|
+
+Enzyme is a Python module to handle video metadata.
+
+Features
+--------
+Parse a MKV file::
+
+ >>> with open('How.I.Met.Your.Mother.S08E21.720p.HDTV.X264-DIMENSION.mkv', 'rb') as f:
+ ... mkv = enzyme.MKV(f)
+ ...
+ >>> mkv.info
+ Info(title=None, duration=0:20:56.005000, date=2013-04-15 14:06:50)
+ >>> mkv.video_tracks
+ [VideoTrack(1, 1280x720, V_MPEG4/ISO/AVC, name=None, language=eng)]
+ >>> mkv.audio_tracks
+ [AudioTrack(2, 6 channel(s), 48000Hz, A_AC3, name=None, language=und)]
+
+
+API Documentation
+-----------------
+
+If you are looking for information on a specific function, class or method,
+this part of the documentation is for you.
+
+.. toctree::
+ :maxdepth: 2
+
+ api/mkv
+ api/parsers
18 enzyme/__init__.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+__title__ = 'enzyme'
+__version__ = '0.3'
+__author__ = 'Antoine Bertin'
+__license__ = 'Apache 2.0'
+__copyright__ = 'Copyright 2013 Antoine Bertin'
+
+
+from .mkv import *
+import logging
+try:
+ from logging import NullHandler
+except ImportError:
+ class NullHandler(logging.Handler):
+ def emit(self, record):
+ pass
+
+logging.getLogger(__name__).addHandler(NullHandler())
13 enzyme/compat.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+import sys
+
+
+_ver = sys.version_info
+is_py3 = _ver[0] == 3
+is_py2 = _ver[0] == 2
+
+
+if is_py2:
+ bytes = lambda x: chr(x[0]) # @ReservedAssignment
+elif is_py3:
+ bytes = bytes # @ReservedAssignment
27 enzyme/exceptions.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+__all__ = ['EnzymeException', 'MalformedMKVError', 'ParserError', 'ReadError', 'SizeError']
+
+
+class EnzymeException(Exception):
+ """Base class for enzyme exceptions"""
+ pass
+
+
+class MalformedMKVError(EnzymeException):
+ """Wrong or malformed element found"""
+ pass
+
+
+class ParserError(EnzymeException):
+ """Base class for exceptions in parsers"""
+ pass
+
+
+class ReadError(ParserError):
+ """Unable to correctly read"""
+ pass
+
+
+class SizeError(ParserError):
+ """Mismatch between the type of the element and the size of its data"""
+ pass
338 enzyme/mkv.py
@@ -0,0 +1,338 @@
+# -*- coding: utf-8 -*-
+from .exceptions import ParserError, MalformedMKVError
+from .parsers import ebml
+from datetime import timedelta
+import logging
+
+
+__all__ = ['VIDEO_TRACK', 'AUDIO_TRACK', 'SUBTITLE_TRACK', 'MKV', 'Info', 'Track', 'VideoTrack',
+ 'AudioTrack', 'SubtitleTrack', 'Tag', 'SimpleTag', 'Chapter']
+logger = logging.getLogger(__name__)
+
+
+# Track types
+VIDEO_TRACK, AUDIO_TRACK, SUBTITLE_TRACK = 0x01, 0x02, 0x11
+
+
+class MKV(object):
+ """Matroska Video file
+
+ :param stream: seekable file-like object
+
+ """
+ def __init__(self, stream):
+ # default attributes
+ self.info = None
+ self.video_tracks = []
+ self.audio_tracks = []
+ self.subtitle_tracks = []
+ self.chapters = []
+ self.tags = []
+
+ try:
+ # get the Segment element
+ logger.info('Reading Segment element')
+ specs = ebml.get_matroska_specs()
+ segments = ebml.parse(stream, specs, ignore_element_names=['EBML'], max_level=0)
+ if not segments:
+ raise MalformedMKVError('No Segment found')
+ if len(segments) > 1:
+ logger.warning('%d segments found, using the first one', len(segments))
+ segment = segments[0]
+
+ # get the SeekHead element
+ logger.info('Reading SeekHead element')
+ stream.seek(segment.position)
+ seek_head = ebml.parse_element(stream, specs)
+ if seek_head.name != 'SeekHead':
+ raise MalformedMKVError('No SeekHead found')
+ seek_head.load(stream, specs, ignore_element_names=['Void', 'CRC-32'])
+
+ # parse interesting informations
+ for seek in seek_head:
+ element_id = ebml.read_element_id(seek['SeekID'].data)
+ element_name = specs[element_id][1]
+ element_position = seek['SeekPosition'].data + segment.position
+ if element_name == 'Info':
+ logger.info('Processing element %s from SeekHead at position %d', element_name, element_position)
+ stream.seek(element_position)
+ self.info = Info.fromelement(ebml.parse_element(stream, specs, True, ignore_element_names=['Void', 'CRC-32']))
+ elif element_name == 'Tracks':
+ logger.info('Processing element %s from SeekHead at position %d', element_name, element_position)
+ stream.seek(element_position)
+ tracks = ebml.parse_element(stream, specs, True, ignore_element_names=['Void', 'CRC-32'])
+ self.video_tracks = [VideoTrack.fromelement(t) for t in tracks if t['TrackType'].data == VIDEO_TRACK]
+ self.audio_tracks = [AudioTrack.fromelement(t) for t in tracks if t['TrackType'].data == AUDIO_TRACK]
+ self.subtitle_tracks = [SubtitleTrack.fromelement(t) for t in tracks if t['TrackType'].data == SUBTITLE_TRACK]
+ elif element_name == 'Chapters':
+ logger.info('Processing element %s from SeekHead at position %d', element_name, element_position)
+ stream.seek(element_position)
+ self.chapters = [Chapter.fromelement(c) for c in ebml.parse_element(stream, specs, True, ignore_element_names=['Void', 'CRC-32'])[0] if c.name == 'ChapterAtom']
+ elif element_name == 'Tags':
+ logger.info('Processing element %s from SeekHead at position %d', element_name, element_position)
+ stream.seek(element_position)
+ self.tags = [Tag.fromelement(t) for t in ebml.parse_element(stream, specs, True, ignore_element_names=['Void', 'CRC-32'])]
+ else:
+ logger.debug('Element %s ignored', element_name)
+ continue
+ except ParserError as e:
+ raise MalformedMKVError('Parsing error: %s' % e)
+
+ def to_dict(self):
+ return {'info': self.info.__dict__, 'video_tracks': [t.__dict__ for t in self.video_tracks],
+ 'audio_tracks': [t.__dict__ for t in self.audio_tracks], 'subtitle_tracks': [t.__dict__ for t in self.subtitle_tracks],
+ 'chapters': [c.__dict__ for c in self.chapters], 'tags': [t.__dict__ for t in self.tags]}
+
+ def __repr__(self):
+ return '%s(%r, %r, %r, %r)' % (self.__class__.__name__, self.info, self.video_tracks, self.audio_tracks, self.subtitle_tracks)
+
+
+class Info(object):
+ """Object for the Info EBML element"""
+ def __init__(self, title=None, duration=None, date_utc=None, timecode_scale=None, muxing_app=None, writing_app=None):
+ self.title = title
+ self.duration = timedelta(microseconds=duration * (timecode_scale or 1000000) // 1000) if duration else None
+ self.date_utc = date_utc
+ self.muxing_app = muxing_app
+ self.writing_app = writing_app
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`Info` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the Info element
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ title = element.get('Title')
+ duration = element.get('Duration')
+ date_utc = element.get('DateUTC')
+ timecode_scale = element.get('TimecodeScale')
+ muxing_app = element.get('MuxingApp')
+ writing_app = element.get('WritingApp')
+ return cls(title, duration, date_utc, timecode_scale, muxing_app, writing_app)
+
+ def __repr__(self):
+ return '%s(title=%s, duration=%s, date=%s)' % (self.__class__.__name__, self.title, self.duration, self.date_utc)
+
+ def __str__(self):
+ return repr(self.__dict__)
+
+
+class Track(object):
+ """Base object for the Tracks EBML element"""
+ def __init__(self, type=None, number=None, name=None, language=None, enabled=None, default=None, forced=None, lacing=None,
+ codec_id=None, codec_name=None):
+ self.type = type
+ self.number = number
+ self.name = name
+ self.language = language
+ self.enabled = enabled
+ self.default = default
+ self.forced = forced
+ self.lacing = lacing
+ self.codec_id = codec_id
+ self.codec_name = codec_name
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`Track` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the Track element
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ type = element.get('TrackType')
+ number = element.get('TrackNumber', 0)
+ name = element.get('Name')
+ language = element.get('Language')
+ enabled = bool(element.get('FlagEnabled', 1))
+ default = bool(element.get('FlagDefault', 1))
+ forced = bool(element.get('FlagForced', 0))
+ lacing = bool(element.get('FlagLacing', 1))
+ codec_id = element.get('CodecID')
+ codec_name = element.get('CodecName')
+ return cls(type=type, number=number, name=name, language=language, enabled=enabled, default=default,
+ forced=forced, lacing=lacing, codec_id=codec_id, codec_name=codec_name)
+
+ def __repr__(self):
+ return '%s(%d, name=%s, language=%s)' % (self.__class__.__name__, self.number, self.name, self.language)
+
+ def __str__(self):
+ return str(self.__dict__)
+
+
+class VideoTrack(Track):
+ """Object for the Tracks EBML element with :data:`VIDEO_TRACK` TrackType"""
+ def __init__(self, width=0, height=0, interlaced=False, stereo_mode=None, crop=None,
+ display_width=None, display_height=None, display_unit=None, aspect_ratio_type=None, **kwargs):
+ super(VideoTrack, self).__init__(**kwargs)
+ self.width = width
+ self.height = height
+ self.interlaced = interlaced
+ self.stereo_mode = stereo_mode
+ self.crop = crop
+ self.display_width = display_width
+ self.display_height = display_height
+ self.display_unit = display_unit
+ self.aspect_ratio_type = aspect_ratio_type
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`VideoTrack` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the Track element with :data:`VIDEO_TRACK` TrackType
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ videotrack = super(VideoTrack, cls).fromelement(element)
+ videotrack.width = element['Video'].get('PixelWidth', 0)
+ videotrack.height = element['Video'].get('PixelHeight', 0)
+ videotrack.interlaced = bool(element['Video'].get('FlagInterlaced', False))
+ videotrack.stereo_mode = element['Video'].get('StereoMode')
+ videotrack.crop = {}
+ if 'PixelCropTop' in element['Video']:
+ videotrack.crop['top'] = element['Video']['PixelCropTop']
+ if 'PixelCropBottom' in element['Video']:
+ videotrack.crop['bottom'] = element['Video']['PixelCropBottom']
+ if 'PixelCropLeft' in element['Video']:
+ videotrack.crop['left'] = element['Video']['PixelCropLeft']
+ if 'PixelCropRight' in element['Video']:
+ videotrack.crop['right'] = element['Video']['PixelCropRight']
+ videotrack.display_width = element['Video'].get('DisplayWidth')
+ videotrack.display_height = element['Video'].get('DisplayHeight')
+ videotrack.display_unit = element['Video'].get('DisplayUnit')
+ videotrack.aspect_ratio_type = element['Video'].get('AspectRatioType')
+ return videotrack
+
+ def __repr__(self):
+ return '%s(%d, %dx%d, %s, name=%s, language=%s)' % (self.__class__.__name__, self.number, self.width, self.height,
+ self.codec_id, self.name, self.language)
+
+ def __str__(self):
+ return str(self.__dict__)
+
+
+class AudioTrack(Track):
+ """Object for the Tracks EBML element with :data:`AUDIO_TRACK` TrackType"""
+ def __init__(self, sampling_frequency=None, channels=None, output_sampling_frequency=None, bit_depth=None, **kwargs):
+ super(AudioTrack, self).__init__(**kwargs)
+ self.sampling_frequency = sampling_frequency
+ self.channels = channels
+ self.output_sampling_frequency = output_sampling_frequency
+ self.bit_depth = bit_depth
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`AudioTrack` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the Track element with :data:`AUDIO_TRACK` TrackType
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ audiotrack = super(AudioTrack, cls).fromelement(element)
+ audiotrack.sampling_frequency = element['Audio'].get('SamplingFrequency', 8000.0)
+ audiotrack.channels = element['Audio'].get('Channels', 1)
+ audiotrack.output_sampling_frequency = element['Audio'].get('OutputSamplingFrequency')
+ audiotrack.bit_depth = element['Audio'].get('BitDepth')
+ return audiotrack
+
+ def __repr__(self):
+ return '%s(%d, %d channel(s), %.0fHz, %s, name=%s, language=%s)' % (self.__class__.__name__, self.number, self.channels,
+ self.sampling_frequency, self.codec_id, self.name, self.language)
+
+
+class SubtitleTrack(Track):
+ """Object for the Tracks EBML element with :data:`SUBTITLE_TRACK` TrackType"""
+ pass
+
+
+class Tag(object):
+ """Object for the Tag EBML element"""
+ def __init__(self, targets=None, simpletags=None):
+ self.targets = targets if targets is not None else []
+ self.simpletags = simpletags if simpletags is not None else []
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`Tag` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the Tag element
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ targets = element['Targets'] if 'Targets' in element else []
+ simpletags = [SimpleTag.fromelement(s) for s in element if s.name == 'SimpleTag']
+ return cls(targets, simpletags)
+
+ def __repr__(self):
+ return '%s(targets=%r, simpletags=%r)' % (self.__class__.__name__, self.targets, self.simpletags)
+
+
+class SimpleTag(object):
+ """Object for the SimpleTag EBML element"""
+ def __init__(self, name, language='und', default=True, string=None, binary=None):
+ self.name = name
+ self.language = language
+ self.default = default
+ self.string = string
+ self.binary = binary
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`SimpleTag` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the SimpleTag element
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ name = element.get('TagName')
+ language = element.get('TagLanguage', 'und')
+ default = element.get('TagDefault', True)
+ string = element.get('TagString')
+ binary = element.get('TagBinary')
+ return cls(name, language, default, string, binary)
+
+ def __repr__(self):
+ return '%s(%s, language=%s, default=%s, string=%s)' % (self.__class__.__name__, self.name, self.language, self.default, self.string)
+
+
+class Chapter(object):
+ """Object for the ChapterAtom and ChapterDisplay EBML element
+
+ .. note::
+ For the sake of simplicity, it is assumed that the ChapterAtom element
+ has no more than 1 ChapterDisplay child element and informations it contains
+ are merged into the :class:`Chapter`
+
+ """
+ def __init__(self, start, hidden=False, enabled=False, end=None, string=None, language=None):
+ self.start = start
+ self.hidden = hidden
+ self.enabled = enabled
+ self.end = end
+ self.string = string
+ self.language = language
+
+ @classmethod
+ def fromelement(cls, element):
+ """Load the :class:`Chapter` from an :class:`~enzyme.parsers.ebml.Element`
+
+ :param element: the ChapterAtom element
+ :type element: :class:`~enzyme.parsers.ebml.Element`
+
+ """
+ start = timedelta(microseconds=element.get('ChapterTimeStart') // 1000)
+ hidden = element.get('ChapterFlagHidden', False)
+ enabled = element.get('ChapterFlagEnabled', True)
+ end = element.get('ChapterTimeEnd')
+ chapterdisplays = [c for c in element if c.name == 'ChapterDisplay']
+ if len(chapterdisplays) > 1:
+ logger.warning('More than 1 (%d) ChapterDisplay element in the ChapterAtom, using the first one', len(chapterdisplays))
+ if chapterdisplays:
+ string = chapterdisplays[0].get('ChapString')
+ language = chapterdisplays[0].get('ChapLanguage')
+ return cls(start, hidden, enabled, end, string, language)
+
+ def __repr__(self):
+ return '%s(%s, enabled=%s)' % (self.__class__.__name__, self.start, self.enabled)
1  enzyme/parsers/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
3  enzyme/parsers/ebml/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+from .core import *
+from .readers import *
239 enzyme/parsers/ebml/core.py
@@ -0,0 +1,239 @@
+# -*- coding: utf-8 -*-
+from ...exceptions import ReadError
+from .readers import *
+from pkg_resources import resource_stream # @UnresolvedImport
+from xml.dom import minidom
+import logging
+
+
+__all__ = ['INTEGER', 'UINTEGER', 'FLOAT', 'STRING', 'UNICODE', 'DATE', 'MASTER', 'BINARY',
+ 'SPEC_TYPES', 'READERS', 'Element', 'MasterElement', 'parse', 'parse_element',
+ 'get_matroska_specs']
+logger = logging.getLogger(__name__)
+
+
+# EBML types
+INTEGER, UINTEGER, FLOAT, STRING, UNICODE, DATE, MASTER, BINARY = range(8)
+
+# Spec types to EBML types mapping
+SPEC_TYPES = {
+ 'integer': INTEGER,
+ 'uinteger': UINTEGER,
+ 'float': FLOAT,
+ 'string': STRING,
+ 'utf-8': UNICODE,
+ 'date': DATE,
+ 'master': MASTER,
+ 'binary': BINARY
+}
+
+# Readers to use per EBML type
+READERS = {
+ INTEGER: read_element_integer,
+ UINTEGER: read_element_uinteger,
+ FLOAT: read_element_float,
+ STRING: read_element_string,
+ UNICODE: read_element_unicode,
+ DATE: read_element_date,
+ BINARY: read_element_binary
+}
+
+
+class Element(object):
+ """Base object of EBML
+
+ :param int id: id of the element, best represented as hexadecimal (0x18538067 for Matroska Segment element)
+ :param type: type of the element
+ :type type: :data:`INTEGER`, :data:`UINTEGER`, :data:`FLOAT`, :data:`STRING`, :data:`UNICODE`, :data:`DATE`, :data:`MASTER` or :data:`BINARY`
+ :param string name: name of the element
+ :param int level: level of the element
+ :param int position: position of element's data
+ :param int size: size of element's data
+ :param data: data as read by the corresponding :data:`READERS`
+
+ """
+ def __init__(self, id=None, type=None, name=None, level=None, position=None, size=None, data=None):
+ self.id = id
+ self.type = type
+ self.name = name
+ self.level = level
+ self.position = position
+ self.size = size
+ self.data = data
+
+ def __repr__(self):
+ return '%s(%s, %r)' % (self.__class__.__name__, self.name, self.data)
+
+
+class MasterElement(Element):
+ """Element of type :data:`MASTER` that has a list of :class:`Element` as its data
+
+ :param int id: id of the element, best represented as hexadecimal (0x18538067 for Matroska Segment element)
+ :param string name: name of the element
+ :param int level: level of the element
+ :param int position: position of element's data
+ :param int size: size of element's data
+ :param data: child elements
+ :type data: list of :class:`Element`
+
+ :class:`MasterElement` implements some magic methods to ease manipulation. Thus, a MasterElement supports
+ the `in` keyword to test for the presence of a child element by its name and gives access to it
+ with a container getter::
+
+ >>> ebml_element = parse(open('test1.mkv', 'rb'), get_matroska_specs())[0]
+ >>> 'EBMLVersion' in ebml_element
+ False
+ >>> 'DocType' in ebml_element
+ True
+ >>> ebml_element['DocType']
+ Element(DocType, u'matroska')
+
+ """
+ def __init__(self, id=None, name=None, level=None, position=None, size=None, data=None):
+ super(MasterElement, self).__init__(id, MASTER, name, level, position, size, data)
+
+ def load(self, stream, specs, ignore_element_types=None, ignore_element_names=None, max_level=None):
+ """Load children :class:`Elements <Element>` with level lower or equal to the `max_level`
+ from the `stream` according to the `specs`
+
+ :param stream: file-like object from which to read
+ :param dict specs: see :ref:`specs`
+ :param int max_level: maximum level for children elements
+ :param list ignore_element_types: list of element types to ignore
+ :param list ignore_element_names: list of element names to ignore
+ :param int max_level: maximum level of elements
+
+ """
+ self.data = parse(stream, specs, self.size, ignore_element_types, ignore_element_names, max_level)
+
+ def get(self, name, default=None):
+ """Convenience method for ``master_element[name].data if name in master_element else default``
+
+ :param string name: the name of the child to get
+ :param default: default value if `name` is not in the :class:`MasterElement`
+ :return: the data of the child :class:`Element` or `default`
+
+ """
+ if name not in self:
+ return default
+ element = self[name]
+ if element.type == MASTER:
+ raise ValueError('%s is a MasterElement' % name)
+ return element.data
+
+ def __getitem__(self, key):
+ if isinstance(key, int):
+ return self.data[key]
+ children = [e for e in self.data if e.name == key]
+ if not children:
+ raise KeyError(key)
+ if len(children) > 1:
+ raise KeyError('More than 1 child with key %s (%d)' % (key, len(children)))
+ return children[0]
+
+ def __contains__(self, item):
+ return len([e for e in self.data if e.name == item]) > 0
+
+ def __iter__(self):
+ return iter(self.data)
+
+
+def parse(stream, specs, size=None, ignore_element_types=None, ignore_element_names=None, max_level=None):
+ """Parse a stream for `size` bytes according to the `specs`
+
+ :param stream: file-like object from which to read
+ :param size: maximum number of bytes to read, None to read all the stream
+ :type size: int or None
+ :param dict specs: see :ref:`specs`
+ :param list ignore_element_types: list of element types to ignore
+ :param list ignore_element_names: list of element names to ignore
+ :param int max_level: maximum level of elements
+ :return: parsed data as a tree of :class:`~enzyme.parsers.ebml.core.Element`
+ :rtype: list
+
+ .. note::
+ If `size` is reached in a middle of an element, reading will continue
+ until the element is fully parsed.
+
+ """
+ ignore_element_types = ignore_element_types if ignore_element_types is not None else []
+ ignore_element_names = ignore_element_names if ignore_element_names is not None else []
+ start = stream.tell()
+ elements = []
+ while size is None or stream.tell() - start < size:
+ try:
+ element = parse_element(stream, specs)
+ if element is None:
+ continue
+ logger.debug('%s %s parsed', element.__class__.__name__, element.name)
+ if element.type in ignore_element_types or element.name in ignore_element_names:
+ logger.info('%s %s ignored', element.__class__.__name__, element.name)
+ if element.type == MASTER:
+ stream.seek(element.size, 1)
+ continue
+ if element.type == MASTER:
+ if max_level is not None and element.level >= max_level:
+ logger.info('Maximum level %d reached for children of %s %s', max_level, element.__class__.__name__, element.name)
+ stream.seek(element.size, 1)
+ else:
+ logger.debug('Loading child elements for %s %s with size %d', element.__class__.__name__, element.name, element.size)
+ element.data = parse(stream, specs, element.size, ignore_element_types, ignore_element_names, max_level)
+ elements.append(element)
+ except ReadError:
+ if size is not None:
+ raise
+ break
+ return elements
+
+
+def parse_element(stream, specs, load_children=False, ignore_element_types=None, ignore_element_names=None, max_level=None):
+ """Extract a single :class:`Element` from the `stream` according to the `specs`
+
+ :param stream: file-like object from which to read
+ :param dict specs: see :ref:`specs`
+ :param bool load_children: load children elements if the parsed element is a :class:`MasterElement`
+ :param list ignore_element_types: list of element types to ignore
+ :param list ignore_element_names: list of element names to ignore
+ :param int max_level: maximum level for children elements
+ :return: the parsed element
+ :rtype: :class:`Element`
+
+ """
+ ignore_element_types = ignore_element_types if ignore_element_types is not None else []
+ ignore_element_names = ignore_element_names if ignore_element_names is not None else []
+ element_id = read_element_id(stream)
+ if element_id is None:
+ raise ReadError('Cannot read element id')
+ element_size = read_element_size(stream)
+ if element_size is None:
+ raise ReadError('Cannot read element size')
+ if element_id not in specs:
+ logger.error('Element with id 0x%x is not in the specs' % element_id)
+ stream.seek(element_size, 1)
+ return None
+ element_type, element_name, element_level = specs[element_id]
+ if element_type == MASTER:
+ element = MasterElement(element_id, element_name, element_level, stream.tell(), element_size)
+ if load_children:
+ element.data = parse(stream, specs, element.size, ignore_element_types, ignore_element_names, max_level)
+ else:
+ element = Element(element_id, element_type, element_name, element_level, stream.tell(), element_size)
+ element.data = READERS[element_type](stream, element_size)
+ return element
+
+
+def get_matroska_specs(webm_only=False):
+ """Get the Matroska specs
+
+ :param bool webm_only: load *only* WebM specs
+ :return: the specs in the appropriate format. See :ref:`specs`
+ :rtype: dict
+
+ """
+ specs = {}
+ with resource_stream(__name__, 'specs/matroska.xml') as resource:
+ xmldoc = minidom.parse(resource)
+ for element in xmldoc.getElementsByTagName('element'):
+ if not webm_only or element.hasAttribute('webm') and element.getAttribute('webm') == '1':
+ specs[int(element.getAttribute('id'), 16)] = (SPEC_TYPES[element.getAttribute('type')], element.getAttribute('name'), int(element.getAttribute('level')))
+ return specs
235 enzyme/parsers/ebml/readers.py
@@ -0,0 +1,235 @@
+# -*- coding: utf-8 -*-
+from ...compat import bytes
+from ...exceptions import ReadError, SizeError
+from datetime import datetime, timedelta
+from io import BytesIO
+from struct import unpack
+
+
+__all__ = ['read_element_id', 'read_element_size', 'read_element_integer', 'read_element_uinteger',
+ 'read_element_float', 'read_element_string', 'read_element_unicode', 'read_element_date',
+ 'read_element_binary']
+
+
+def _read(stream, size):
+ """Read the `stream` for *exactly* `size` bytes and raise an exception if
+ less than `size` bytes are actually read
+
+ :param stream: file-like object from which to read
+ :param int size: number of bytes to read
+ :raise ReadError: when less than `size` bytes are actually read
+ :return: read data from the `stream`
+ :rtype: bytes
+
+ """
+ data = stream.read(size)
+ if len(data) < size:
+ raise ReadError('Less than %d bytes read (%d)' % (size, len(data)))
+ return data
+
+
+def read_element_id(stream):
+ """Read the Element ID
+
+ :param stream: file-like object from which to read
+ :raise ReadError: when not all the required bytes could be read
+ :return: the id of the element
+ :rtype: int
+
+ """
+ char = _read(stream, 1)
+ byte = ord(char)
+ if byte & 0x80:
+ return byte
+ elif byte & 0x40:
+ return unpack('>H', char + _read(stream, 1))[0]
+ elif byte & 0x20:
+ b, h = unpack('>BH', char + _read(stream, 2))
+ return b * 2 ** 16 + h
+ elif byte & 0x10:
+ return unpack('>L', char + _read(stream, 3))[0]
+ else:
+ ValueError('Not an Element ID')
+
+
+def read_element_size(stream):
+ """Read the Element Size
+
+ :param stream: file-like object from which to read
+ :raise ReadError: when not all the required bytes could be read
+ :return: the size of element's data
+ :rtype: int
+
+ """
+ char = _read(stream, 1)
+ byte = ord(char)
+ if byte & 0x80:
+ return unpack('>B', bytes((byte ^ 0x80,)))[0]
+ elif byte & 0x40:
+ return unpack('>H', bytes((byte ^ 0x40,)) + _read(stream, 1))[0]
+ elif byte & 0x20:
+ b, h = unpack('>BH', bytes((byte ^ 0x20,)) + _read(stream, 2))
+ return b * 2 ** 16 + h
+ elif byte & 0x10:
+ return unpack('>L', bytes((byte ^ 0x10,)) + _read(stream, 3))[0]
+ elif byte & 0x08:
+ b, l = unpack('>BL', bytes((byte ^ 0x08,)) + _read(stream, 4))
+ return b * 2 ** 32 + l
+ elif byte & 0x04:
+ h, l = unpack('>HL', bytes((byte ^ 0x04,)) + _read(stream, 5))
+ return h * 2 ** 32 + l
+ elif byte & 0x02:
+ b, h, l = unpack('>BHL', bytes((byte ^ 0x02,)) + _read(stream, 6))
+ return b * 2 ** 48 + h * 2 ** 32 + l
+ elif byte & 0x01:
+ return unpack('>Q', bytes((byte ^ 0x01,)) + _read(stream, 7))[0]
+ else:
+ ValueError('Not an Element Size')
+
+
+def read_element_integer(stream, size):
+ """Read the Element Data of type :data:`INTEGER`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: the read integer
+ :rtype: int
+
+ """
+ if size == 1:
+ return unpack('>b', _read(stream, 1))[0]
+ elif size == 2:
+ return unpack('>h', _read(stream, 2))[0]
+ elif size == 3:
+ b, h = unpack('>bH', _read(stream, 3))
+ return b * 2 ** 16 + h
+ elif size == 4:
+ return unpack('>l', _read(stream, 4))[0]
+ elif size == 5:
+ b, l = unpack('>bL', _read(stream, 5))
+ return b * 2 ** 32 + l
+ elif size == 6:
+ h, l = unpack('>hL', _read(stream, 6))
+ return h * 2 ** 32 + l
+ elif size == 7:
+ b, h, l = unpack('>bHL', _read(stream, 7))
+ return b * 2 ** 48 + h * 2 ** 32 + l
+ elif size == 8:
+ return unpack('>q', _read(stream, 8))[0]
+ else:
+ raise SizeError(size)
+
+
+def read_element_uinteger(stream, size):
+ """Read the Element Data of type :data:`UINTEGER`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: the read unsigned integer
+ :rtype: int
+
+ """
+ if size == 1:
+ return unpack('>B', _read(stream, 1))[0]
+ elif size == 2:
+ return unpack('>H', _read(stream, 2))[0]
+ elif size == 3:
+ b, h = unpack('>BH', _read(stream, 3))
+ return b * 2 ** 16 + h
+ elif size == 4:
+ return unpack('>L', _read(stream, 4))[0]
+ elif size == 5:
+ b, l = unpack('>BL', _read(stream, 5))
+ return b * 2 ** 32 + l
+ elif size == 6:
+ h, l = unpack('>HL', _read(stream, 6))
+ return h * 2 ** 32 + l
+ elif size == 7:
+ b, h, l = unpack('>BHL', _read(stream, 7))
+ return b * 2 ** 48 + h * 2 ** 32 + l
+ elif size == 8:
+ return unpack('>Q', _read(stream, 8))[0]
+ else:
+ raise SizeError(size)
+
+
+def read_element_float(stream, size):
+ """Read the Element Data of type :data:`FLOAT`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: the read float
+ :rtype: float
+
+ """
+ if size == 4:
+ return unpack('>f', _read(stream, 4))[0]
+ elif size == 8:
+ return unpack('>d', _read(stream, 8))[0]
+ else:
+ raise SizeError(size)
+
+
+def read_element_string(stream, size):
+ """Read the Element Data of type :data:`STRING`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: the read ascii-decoded string
+ :rtype: unicode
+
+ """
+ return _read(stream, size).decode('ascii')
+
+
+def read_element_unicode(stream, size):
+ """Read the Element Data of type :data:`UNICODE`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: the read utf-8-decoded string
+ :rtype: unicode
+
+ """
+ return _read(stream, size).decode('utf-8')
+
+
+def read_element_date(stream, size):
+ """Read the Element Data of type :data:`DATE`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: the read date
+ :rtype: datetime
+
+ """
+ if size != 8:
+ raise SizeError(size)
+ nanoseconds = unpack('>q', _read(stream, 8))[0]
+ return datetime(2001, 1, 1, 0, 0, 0, 0, None) + timedelta(microseconds=nanoseconds // 1000)
+
+
+def read_element_binary(stream, size):
+ """Read the Element Data of type :data:`BINARY`
+
+ :param stream: file-like object from which to read
+ :param int size: size of element's data
+ :raise ReadError: when not all the required bytes could be read
+ :raise SizeError: if size is incorrect
+ :return: raw binary data
+ :rtype: bytes
+
+ """
+ return BytesIO(stream.read(size))
224 enzyme/parsers/ebml/specs/matroska.xml
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="utf-8"?>
+<table>
+ <element name="EBML" level="0" id="0x1A45DFA3" type="master" mandatory="1" multiple="1" minver="1">Set the EBML characteristics of the data to follow. Each EBML document has to start with this.</element>
+ <element name="EBMLVersion" level="1" id="0x4286" type="uinteger" mandatory="1" default="1" minver="1">The version of EBML parser used to create the file.</element>
+ <element name="EBMLReadVersion" level="1" id="0x42F7" type="uinteger" mandatory="1" default="1" minver="1">The minimum EBML version a parser has to support to read this file.</element>
+ <element name="EBMLMaxIDLength" level="1" id="0x42F2" type="uinteger" mandatory="1" default="4" minver="1">The maximum length of the IDs you'll find in this file (4 or less in Matroska).</element>
+ <element name="EBMLMaxSizeLength" level="1" id="0x42F3" type="uinteger" mandatory="1" default="8" minver="1">The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.</element>
+ <element name="DocType" level="1" id="0x4282" type="string" mandatory="1" default="matroska" minver="1">A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files.</element>
+ <element name="DocTypeVersion" level="1" id="0x4287" type="uinteger" mandatory="1" default="1" minver="1">The version of DocType interpreter used to create the file.</element>
+ <element name="DocTypeReadVersion" level="1" id="0x4285" type="uinteger" mandatory="1" default="1" minver="1">The minimum DocType version an interpreter has to support to read this file.</element>
+ <element name="Void" level="-1" id="0xEC" type="binary" minver="1">Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use.</element>
+ <element name="CRC-32" level="-1" id="0xBF" type="binary" minver="1" webm="0">The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian</element>
+ <element name="SignatureSlot" level="-1" id="0x1B538667" type="master" multiple="1" webm="0">Contain signature of some (coming) elements in the stream.</element>
+ <element name="SignatureAlgo" level="1" id="0x7E8A" type="uinteger" webm="0">Signature algorithm used (1=RSA, 2=elliptic).</element>
+ <element name="SignatureHash" level="1" id="0x7E9A" type="uinteger" webm="0">Hash algorithm used (1=SHA1-160, 2=MD5).</element>
+ <element name="SignaturePublicKey" level="1" id="0x7EA5" type="binary" webm="0">The public key to use with the algorithm (in the case of a PKI-based signature).</element>
+ <element name="Signature" level="1" id="0x7EB5" type="binary" webm="0">The signature of the data (until a new.</element>
+ <element name="SignatureElements" level="1" id="0x7E5B" type="master" webm="0">Contains elements that will be used to compute the signature.</element>
+ <element name="SignatureElementList" level="2" id="0x7E7B" type="master" multiple="1" webm="0">A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: <i>Cluster|Block|BlockAdditional</i> means that the BlockAdditional of all Blocks in all Clusters is used for encryption.</element>
+ <element name="SignedElement" level="3" id="0x6532" type="binary" multiple="1" webm="0">An element ID whose data will be used to compute the signature.</element>
+ <element name="Segment" level="0" id="0x18538067" type="master" mandatory="1" multiple="1" minver="1">This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.</element>
+ <element name="SeekHead" cppname="SeekHeader" level="1" id="0x114D9B74" type="master" multiple="1" minver="1">Contains the <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">position</a> of other level 1 elements.</element>
+ <element name="Seek" cppname="SeekPoint" level="2" id="0x4DBB" type="master" mandatory="1" multiple="1" minver="1">Contains a single seek entry to an EBML element.</element>
+ <element name="SeekID" level="3" id="0x53AB" type="binary" mandatory="1" minver="1">The binary ID corresponding to the element name.</element>
+ <element name="SeekPosition" level="3" id="0x53AC" type="uinteger" mandatory="1" minver="1">The <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">position</a> of the element in the segment in octets (0 = first level 1 element).</element>
+ <element name="Info" level="1" id="0x1549A966" type="master" mandatory="1" multiple="1" minver="1">Contains miscellaneous general information and statistics on the file.</element>
+ <element name="SegmentUID" level="2" id="0x73A4" type="binary" minver="1" webm="0" range="not 0" bytesize="16">A randomly generated unique ID to identify the current segment between many others (128 bits).</element>
+ <element name="SegmentFilename" level="2" id="0x7384" type="utf-8" minver="1" webm="0">A filename corresponding to this segment.</element>
+ <element name="PrevUID" level="2" id="0x3CB923" type="binary" minver="1" webm="0" bytesize="16">A unique ID to identify the previous chained segment (128 bits).</element>
+ <element name="PrevFilename" level="2" id="0x3C83AB" type="utf-8" minver="1" webm="0">An escaped filename corresponding to the previous segment.</element>
+ <element name="NextUID" level="2" id="0x3EB923" type="binary" minver="1" webm="0" bytesize="16">A unique ID to identify the next chained segment (128 bits).</element>
+ <element name="NextFilename" level="2" id="0x3E83BB" type="utf-8" minver="1" webm="0">An escaped filename corresponding to the next segment.</element>
+ <element name="SegmentFamily" level="2" id="0x4444" type="binary" multiple="1" minver="1" webm="0" bytesize="16">A randomly generated unique ID that all segments related to each other must use (128 bits).</element>
+ <element name="ChapterTranslate" level="2" id="0x6924" type="master" multiple="1" minver="1" webm="0">A tuple of corresponding ID used by chapter codecs to represent this segment.</element>
+ <element name="ChapterTranslateEditionUID" level="3" id="0x69FC" type="uinteger" multiple="1" minver="1" webm="0">Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.</element>
+ <element name="ChapterTranslateCodec" level="3" id="0x69BF" type="uinteger" mandatory="1" minver="1" webm="0">The <a href="http://www.matroska.org/technical/specs/index.html#ChapProcessCodecID">chapter codec</a> using this ID (0: Matroska Script, 1: DVD-menu).</element>
+ <element name="ChapterTranslateID" level="3" id="0x69A5" type="binary" mandatory="1" minver="1" webm="0">The binary value used to represent this segment in the chapter codec data. The format depends on the <a href="http://www.matroska.org/technical/specs/chapters/index.html#ChapProcessCodecID">ChapProcessCodecID</a> used.</element>
+ <element name="TimecodeScale" level="2" id="0x2AD7B1" type="uinteger" mandatory="1" minver="1" default="1000000">Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds).</element>
+ <!-- <element name="TimecodeScaleDenominator" level="2" id="0x2AD7B2" type="uinteger" mandatory="1" minver="4" default="1000000000">Timecode scale numerator, see <a href="http://www.matroska.org/technical/specs/index.html#TimecodeScale">TimecodeScale</a>.</element>
+ TimecodeScale When combined with <a href="http://www.matroska.org/technical/specs/index.html#TimecodeScaleDenominator">TimecodeScaleDenominator</a> the Timecode scale is given by the fraction TimecodeScale/TimecodeScaleDenominator in seconds.-->
+ <element name="Duration" level="2" id="0x4489" type="float" minver="1" range="&gt; 0">Duration of the segment (based on TimecodeScale).</element>
+ <element name="DateUTC" level="2" id="0x4461" type="date" minver="1">Date of the origin of timecode (value 0), i.e. production date.</element>
+ <element name="Title" level="2" id="0x7BA9" type="utf-8" minver="1" webm="0">General name of the segment.</element>
+ <element name="MuxingApp" level="2" id="0x4D80" type="utf-8" mandatory="1" minver="1">Muxing application or library ("libmatroska-0.4.3").</element>
+ <element name="WritingApp" level="2" id="0x5741" type="utf-8" mandatory="1" minver="1">Writing application ("mkvmerge-0.3.3").</element>
+ <element name="Cluster" level="1" id="0x1F43B675" type="master" multiple="1" minver="1">The lower level element containing the (monolithic) Block structure.</element>
+ <element name="Timecode" cppname="ClusterTimecode" level="2" id="0xE7" type="uinteger" mandatory="1" minver="1">Absolute timecode of the cluster (based on TimecodeScale).</element>
+ <element name="SilentTracks" cppname="ClusterSilentTracks" level="2" id="0x5854" type="master" minver="1" webm="0">The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.</element>
+ <element name="SilentTrackNumber" cppname="ClusterSilentTrackNumber" level="3" id="0x58D7" type="uinteger" multiple="1" minver="1" webm="0">One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.</element>
+ <element name="Position" cppname="ClusterPosition" level="2" id="0xA7" type="uinteger" minver="1" webm="0">The <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">Position</a> of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.</element>
+ <element name="PrevSize" cppname="ClusterPrevSize" level="2" id="0xAB" type="uinteger" minver="1">Size of the previous Cluster, in octets. Can be useful for backward playing.</element>
+ <element name="SimpleBlock" level="2" id="0xA3" type="binary" multiple="1" minver="2" webm="1" divx="1">Similar to <a href="http://www.matroska.org/technical/specs/index.html#Block">Block</a> but without all the extra information, mostly used to reduced overhead when no extra feature is needed. (see <a href="http://www.matroska.org/technical/specs/index.html#simpleblock_structure">SimpleBlock Structure</a>)</element>
+ <element name="BlockGroup" level="2" id="0xA0" type="master" multiple="1" minver="1">Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.</element>
+ <element name="Block" level="3" id="0xA1" type="binary" mandatory="1" minver="1">Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode. (see <a href="http://www.matroska.org/technical/specs/index.html#block_structure">Block Structure</a>)</element>
+ <element name="BlockVirtual" level="3" id="0xA2" type="binary" webm="0">A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see <a href="http://www.matroska.org/technical/specs/index.html#block_virtual">Block Virtual</a>)</element>
+ <element name="BlockAdditions" level="3" id="0x75A1" type="master" minver="1" webm="0">Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.</element>
+ <element name="BlockMore" level="4" id="0xA6" type="master" mandatory="1" multiple="1" minver="1" webm="0">Contain the BlockAdditional and some parameters.</element>
+ <element name="BlockAddID" level="5" id="0xEE" type="uinteger" mandatory="1" minver="1" webm="0" default="1" range="not 0">An ID to identify the BlockAdditional level.</element>
+ <element name="BlockAdditional" level="5" id="0xA5" type="binary" mandatory="1" minver="1" webm="0">Interpreted by the codec as it wishes (using the BlockAddID).</element>
+ <element name="BlockDuration" level="3" id="0x9B" type="uinteger" minver="1" default="TrackDuration">The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe.</element>
+ <element name="ReferencePriority" cppname="FlagReferenced" level="3" id="0xFA" type="uinteger" mandatory="1" minver="1" webm="0" default="0">This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.</element>
+ <element name="ReferenceBlock" level="3" id="0xFB" type="integer" multiple="1" minver="1">Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to.</element>
+ <element name="ReferenceVirtual" level="3" id="0xFD" type="integer" webm="0">Relative <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">position</a> of the data that should be in position of the virtual block.</element>
+ <element name="CodecState" level="3" id="0xA4" type="binary" minver="2" webm="0">The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.</element>
+ <element name="Slices" level="3" id="0x8E" type="master" minver="1" divx="0">Contains slices description.</element>
+ <element name="TimeSlice" level="4" id="0xE8" type="master" multiple="1" minver="1" divx="0">Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.</element>
+ <element name="LaceNumber" cppname="SliceLaceNumber" level="5" id="0xCC" type="uinteger" minver="1" default="0" divx="0">The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.</element>
+ <element name="FrameNumber" cppname="SliceFrameNumber" level="5" id="0xCD" type="uinteger" default="0">The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).</element>
+ <element name="BlockAdditionID" cppname="SliceBlockAddID" level="5" id="0xCB" type="uinteger" default="0">The ID of the BlockAdditional element (0 is the main Block).</element>
+ <element name="Delay" cppname="SliceDelay" level="5" id="0xCE" type="uinteger" default="0">The (scaled) delay to apply to the element.</element>
+ <element name="SliceDuration" level="5" id="0xCF" type="uinteger" default="0">The (scaled) duration to apply to the element.</element>
+ <element name="ReferenceFrame" level="3" id="0xC8" type="master" multiple="0" minver="0" webm="0" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="ReferenceOffset" level="4" id="0xC9" type="uinteger" multiple="0" mandatory="1" minver="0" webm="0" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="ReferenceTimeCode" level="4" id="0xCA" type="uinteger" multiple="0" mandatory="1" minver="0" webm="0" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="EncryptedBlock" level="2" id="0xAF" type="binary" multiple="1" webm="0">Similar to <a href="http://www.matroska.org/technical/specs/index.html#SimpleBlock">SimpleBlock</a> but the data inside the Block are Transformed (encrypt and/or signed). (see <a href="http://www.matroska.org/technical/specs/index.html#encryptedblock_structure">EncryptedBlock Structure</a>)</element>
+ <element name="Tracks" level="1" id="0x1654AE6B" type="master" multiple="1" minver="1">A top-level block of information with many tracks described.</element>
+ <element name="TrackEntry" level="2" id="0xAE" type="master" mandatory="1" multiple="1" minver="1">Describes a track with all elements.</element>
+ <element name="TrackNumber" level="3" id="0xD7" type="uinteger" mandatory="1" minver="1" range="not 0">The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).</element>
+ <element name="TrackUID" level="3" id="0x73C5" type="uinteger" mandatory="1" minver="1" range="not 0">A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.</element>
+ <element name="TrackType" level="3" id="0x83" type="uinteger" mandatory="1" minver="1" range="1-254">A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).</element>
+ <element name="FlagEnabled" cppname="TrackFlagEnabled" level="3" id="0xB9" type="uinteger" mandatory="1" minver="2" webm="1" default="1" range="0-1">Set if the track is usable. (1 bit)</element>
+ <element name="FlagDefault" cppname="TrackFlagDefault" level="3" id="0x88" type="uinteger" mandatory="1" minver="1" default="1" range="0-1">Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)</element>
+ <element name="FlagForced" cppname="TrackFlagForced" level="3" id="0x55AA" type="uinteger" mandatory="1" minver="1" default="0" range="0-1">Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)</element>
+ <element name="FlagLacing" cppname="TrackFlagLacing" level="3" id="0x9C" type="uinteger" mandatory="1" minver="1" default="1" range="0-1">Set if the track may contain blocks using lacing. (1 bit)</element>
+ <element name="MinCache" cppname="TrackMinCache" level="3" id="0x6DE7" type="uinteger" mandatory="1" minver="1" webm="0" default="0">The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.</element>
+ <element name="MaxCache" cppname="TrackMaxCache" level="3" id="0x6DF8" type="uinteger" minver="1" webm="0">The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.</element>
+ <element name="DefaultDuration" cppname="TrackDefaultDuration" level="3" id="0x23E383" type="uinteger" minver="1" range="not 0">Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block).</element>
+ <element name="TrackTimecodeScale" level="3" id="0x23314F" type="float" mandatory="1" minver="1" maxver="3" webm="0" default="1.0" range="&gt; 0">DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs).</element>
+ <element name="TrackOffset" level="3" id="0x537F" type="integer" webm="0" default="0">A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track.</element>
+ <element name="MaxBlockAdditionID" level="3" id="0x55EE" type="uinteger" mandatory="1" minver="1" webm="0" default="0">The maximum value of <a href="http://www.matroska.org/technical/specs/index.html#BlockAddID">BlockAddID</a>. A value 0 means there is no <a href="http://www.matroska.org/technical/specs/index.html#BlockAdditions">BlockAdditions</a> for this track.</element>
+ <element name="Name" cppname="TrackName" level="3" id="0x536E" type="utf-8" minver="1">A human-readable track name.</element>
+ <element name="Language" cppname="TrackLanguage" level="3" id="0x22B59C" type="string" minver="1" default="eng">Specifies the language of the track in the <a href="http://www.matroska.org/technical/specs/index.html#languages">Matroska languages form</a>.</element>
+ <element name="CodecID" level="3" id="0x86" type="string" mandatory="1" minver="1">An ID corresponding to the codec, see the <a href="http://www.matroska.org/technical/specs/codecid/index.html">codec page</a> for more info.</element>
+ <element name="CodecPrivate" level="3" id="0x63A2" type="binary" minver="1">Private data only known to the codec.</element>
+ <element name="CodecName" level="3" id="0x258688" type="utf-8" minver="1">A human-readable string specifying the codec.</element>
+ <element name="AttachmentLink" cppname="TrackAttachmentLink" level="3" id="0x7446" type="uinteger" minver="1" webm="0" range="not 0">The UID of an attachment that is used by this codec.</element>
+ <element name="CodecSettings" level="3" id="0x3A9697" type="utf-8" webm="0">A string describing the encoding setting used.</element>
+ <element name="CodecInfoURL" level="3" id="0x3B4040" type="string" multiple="1" webm="0">A URL to find information about the codec used.</element>
+ <element name="CodecDownloadURL" level="3" id="0x26B240" type="string" multiple="1" webm="0">A URL to download about the codec used.</element>
+ <element name="CodecDecodeAll" level="3" id="0xAA" type="uinteger" mandatory="1" minver="2" webm="0" default="1" range="0-1">The codec can decode potentially damaged data (1 bit).</element>
+ <element name="TrackOverlay" level="3" id="0x6FAB" type="uinteger" multiple="1" minver="1" webm="0">Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see <a href="http://www.matroska.org/technical/specs/index.html#SilentTracks">SilentTracks</a>) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.</element>
+ <element name="TrackTranslate" level="3" id="0x6624" type="master" multiple="1" minver="1" webm="0">The track identification for the given Chapter Codec.</element>
+ <element name="TrackTranslateEditionUID" level="4" id="0x66FC" type="uinteger" multiple="1" minver="1" webm="0">Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.</element>
+ <element name="TrackTranslateCodec" level="4" id="0x66BF" type="uinteger" mandatory="1" minver="1" webm="0">The <a href="http://www.matroska.org/technical/specs/index.html#ChapProcessCodecID">chapter codec</a> using this ID (0: Matroska Script, 1: DVD-menu).</element>
+ <element name="TrackTranslateTrackID" level="4" id="0x66A5" type="binary" mandatory="1" minver="1" webm="0">The binary value used to represent this track in the chapter codec data. The format depends on the <a href="http://www.matroska.org/technical/specs/index.html#ChapProcessCodecID">ChapProcessCodecID</a> used.</element>
+ <element name="Video" cppname="TrackVideo" level="3" id="0xE0" type="master" minver="1">Video settings.</element>
+ <element name="FlagInterlaced" cppname="VideoFlagInterlaced" level="4" id="0x9A" type="uinteger" mandatory="1" minver="2" webm="1" default="0" range="0-1">Set if the video is interlaced. (1 bit)</element>
+ <element name="StereoMode" cppname="VideoStereoMode" level="4" id="0x53B8" type="uinteger" minver="3" webm="1" default="0">Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on <a href="http://www.matroska.org/technical/specs/notes.html#3D">3D support in the Specification Notes</a>.</element>
+ <element name="OldStereoMode" level="4" id="0x53B9" type="uinteger" maxver="0" webm="0" divx="0">DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes).</element>
+ <element name="PixelWidth" cppname="VideoPixelWidth" level="4" id="0xB0" type="uinteger" mandatory="1" minver="1" range="not 0">Width of the encoded video frames in pixels.</element>
+ <element name="PixelHeight" cppname="VideoPixelHeight" level="4" id="0xBA" type="uinteger" mandatory="1" minver="1" range="not 0">Height of the encoded video frames in pixels.</element>
+ <element name="PixelCropBottom" cppname="VideoPixelCropBottom" level="4" id="0x54AA" type="uinteger" minver="1" default="0">The number of video pixels to remove at the bottom of the image (for HDTV content).</element>
+ <element name="PixelCropTop" cppname="VideoPixelCropTop" level="4" id="0x54BB" type="uinteger" minver="1" default="0">The number of video pixels to remove at the top of the image.</element>
+ <element name="PixelCropLeft" cppname="VideoPixelCropLeft" level="4" id="0x54CC" type="uinteger" minver="1" default="0">The number of video pixels to remove on the left of the image.</element>
+ <element name="PixelCropRight" cppname="VideoPixelCropRight" level="4" id="0x54DD" type="uinteger" minver="1" default="0">The number of video pixels to remove on the right of the image.</element>
+ <element name="DisplayWidth" cppname="VideoDisplayWidth" level="4" id="0x54B0" type="uinteger" minver="1" default="PixelWidth" range="not 0">Width of the video frames to display. The default value is only valid when <a href="http://www.matroska.org/technical/specs/index.html#DisplayUnit">DisplayUnit</a> is 0.</element>
+ <element name="DisplayHeight" cppname="VideoDisplayHeight" level="4" id="0x54BA" type="uinteger" minver="1" default="PixelHeight" range="not 0">Height of the video frames to display. The default value is only valid when <a href="http://www.matroska.org/technical/specs/index.html#DisplayUnit">DisplayUnit</a> is 0.</element>
+ <element name="DisplayUnit" cppname="VideoDisplayUnit" level="4" id="0x54B2" type="uinteger" minver="1" default="0">How DisplayWidth &amp; DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio).</element>
+ <element name="AspectRatioType" cppname="VideoAspectRatio" level="4" id="0x54B3" type="uinteger" minver="1" default="0">Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).</element>
+ <element name="ColourSpace" cppname="VideoColourSpace" level="4" id="0x2EB524" type="binary" minver="1" webm="0" bytesize="4">Same value as in AVI (32 bits).</element>
+ <element name="GammaValue" cppname="VideoGamma" level="4" id="0x2FB523" type="float" webm="0" range="&gt; 0">Gamma Value.</element>
+ <element name="FrameRate" cppname="VideoFrameRate" level="4" id="0x2383E3" type="float" range="&gt; 0">Number of frames per second. <strong>Informational</strong> only.</element>
+ <element name="Audio" cppname="TrackAudio" level="3" id="0xE1" type="master" minver="1">Audio settings.</element>
+ <element name="SamplingFrequency" cppname="AudioSamplingFreq" level="4" id="0xB5" type="float" mandatory="1" minver="1" default="8000.0" range="&gt; 0">Sampling frequency in Hz.</element>
+ <element name="OutputSamplingFrequency" cppname="AudioOutputSamplingFreq" level="4" id="0x78B5" type="float" minver="1" default="Sampling Frequency" range="&gt; 0">Real output sampling frequency in Hz (used for SBR techniques).</element>
+ <element name="Channels" cppname="AudioChannels" level="4" id="0x9F" type="uinteger" mandatory="1" minver="1" default="1" range="not 0">Numbers of channels in the track.</element>
+ <element name="ChannelPositions" cppname="AudioPosition" level="4" id="0x7D7B" type="binary" webm="0">Table of horizontal angles for each successive channel, see <a href="http://www.matroska.org/technical/specs/index.html#channelposition">appendix</a>.</element>
+ <element name="BitDepth" cppname="AudioBitDepth" level="4" id="0x6264" type="uinteger" minver="1" range="not 0">Bits per sample, mostly used for PCM.</element>
+ <element name="TrackOperation" level="3" id="0xE2" type="master" minver="3" webm="0">Operation that needs to be applied on tracks to create this virtual track. For more details <a href="http://www.matroska.org/technical/specs/notes.html#TrackOperation">look at the Specification Notes</a> on the subject.</element>
+ <element name="TrackCombinePlanes" level="4" id="0xE3" type="master" minver="3" webm="0">Contains the list of all video plane tracks that need to be combined to create this 3D track</element>
+ <element name="TrackPlane" level="5" id="0xE4" type="master" mandatory="1" multiple="1" minver="3" webm="0">Contains a video plane track that need to be combined to create this 3D track</element>
+ <element name="TrackPlaneUID" level="6" id="0xE5" type="uinteger" mandatory="1" minver="3" webm="0" range="not 0">The trackUID number of the track representing the plane.</element>
+ <element name="TrackPlaneType" level="6" id="0xE6" type="uinteger" mandatory="1" minver="3" webm="0">The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background).</element>
+ <element name="TrackJoinBlocks" level="4" id="0xE9" type="master" minver="3" webm="0">Contains the list of all tracks whose Blocks need to be combined to create this virtual track</element>
+ <element name="TrackJoinUID" level="5" id="0xED" type="uinteger" mandatory="1" multiple="1" minver="3" webm="0" range="not 0">The trackUID number of a track whose blocks are used to create this virtual track.</element>
+ <element name="TrickTrackUID" level="3" id="0xC0" type="uinteger" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="TrickTrackSegmentUID" level="3" id="0xC1" type="binary" divx="1" bytesize="16"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="TrickTrackFlag" level="3" id="0xC6" type="uinteger" divx="1" default="0"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="TrickMasterTrackUID" level="3" id="0xC7" type="uinteger" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="TrickMasterTrackSegmentUID" level="3" id="0xC4" type="binary" divx="1" bytesize="16"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/Smooth_FF_RW">DivX trick track extenstions</a></element>
+ <element name="ContentEncodings" level="3" id="0x6D80" type="master" minver="1" webm="0">Settings for several content encoding mechanisms like compression or encryption.</element>
+ <element name="ContentEncoding" level="4" id="0x6240" type="master" mandatory="1" multiple="1" minver="1" webm="0">Settings for one content encoding like compression or encryption.</element>
+ <element name="ContentEncodingOrder" level="5" id="0x5031" type="uinteger" mandatory="1" minver="1" webm="0" default="0">Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment.</element>
+ <element name="ContentEncodingScope" level="5" id="0x5032" type="uinteger" mandatory="1" minver="1" webm="0" default="1" range="not 0">A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values:<br/> 1 - all frame contents,<br/> 2 - the track's private data,<br/> 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)</element>
+ <element name="ContentEncodingType" level="5" id="0x5033" type="uinteger" mandatory="1" minver="1" webm="0" default="0">A value describing what kind of transformation has been done. Possible values:<br/> 0 - compression,<br/> 1 - encryption</element>
+ <element name="ContentCompression" level="5" id="0x5034" type="master" minver="1" webm="0">Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.</element>
+ <element name="ContentCompAlgo" level="6" id="0x4254" type="uinteger" mandatory="1" minver="1" webm="0" default="0">The compression algorithm used. Algorithms that have been specified so far are:<br/> 0 - zlib,<br/> <del>1 - bzlib,</del><br/> <del>2 - lzo1x</del><br/> 3 - Header Stripping</element>
+ <element name="ContentCompSettings" level="6" id="0x4255" type="binary" minver="1" webm="0">Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.</element>
+ <element name="ContentEncryption" level="5" id="0x5035" type="master" minver="1" webm="0">Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.</element>
+ <element name="ContentEncAlgo" level="6" id="0x47E1" type="uinteger" minver="1" webm="0" default="0">The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values:<br/> 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES</element>
+ <element name="ContentEncKeyID" level="6" id="0x47E2" type="binary" minver="1" webm="0">For public key algorithms this is the ID of the public key the the data was encrypted with.</element>
+ <element name="ContentSignature" level="6" id="0x47E3" type="binary" minver="1" webm="0">A cryptographic signature of the contents.</element>
+ <element name="ContentSigKeyID" level="6" id="0x47E4" type="binary" minver="1" webm="0">This is the ID of the private key the data was signed with.</element>
+ <element name="ContentSigAlgo" level="6" id="0x47E5" type="uinteger" minver="1" webm="0" default="0">The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:<br/> 1 - RSA</element>
+ <element name="ContentSigHashAlgo" level="6" id="0x47E6" type="uinteger" minver="1" webm="0" default="0">The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:<br/> 1 - SHA1-160<br/> 2 - MD5</element>
+ <element name="Cues" level="1" id="0x1C53BB6B" type="master" minver="1">A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non <a href="http://www.matroska.org/technical/streaming/index.hmtl">"live" streams</a>.</element>
+ <element name="CuePoint" level="2" id="0xBB" type="master" mandatory="1" multiple="1" minver="1">Contains all information relative to a seek point in the segment.</element>
+ <element name="CueTime" level="3" id="0xB3" type="uinteger" mandatory="1" minver="1">Absolute timecode according to the segment time base.</element>
+ <element name="CueTrackPositions" level="3" id="0xB7" type="master" mandatory="1" multiple="1" minver="1">Contain positions for different tracks corresponding to the timecode.</element>
+ <element name="CueTrack" level="4" id="0xF7" type="uinteger" mandatory="1" minver="1" range="not 0">The track for which a position is given.</element>
+ <element name="CueClusterPosition" level="4" id="0xF1" type="uinteger" mandatory="1" minver="1">The <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">position</a> of the Cluster containing the required Block.</element>
+ <element name="CueRelativePosition" level="4" id="0xF0" type="uinteger" mandatory="0" minver="4" webm="0">The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.</element>
+ <element name="CueDuration" level="4" id="0xB2" type="uinteger" mandatory="0" minver="4" webm="0">The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues.</element>
+ <element name="CueBlockNumber" level="4" id="0x5378" type="uinteger" minver="1" default="1" range="not 0">Number of the Block in the specified Cluster.</element>
+ <element name="CueCodecState" level="4" id="0xEA" type="uinteger" minver="2" webm="0" default="0">The <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">position</a> of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.</element>
+ <element name="CueReference" level="4" id="0xDB" type="master" multiple="1" minver="2" webm="0">The Clusters containing the required referenced Blocks.</element>
+ <element name="CueRefTime" level="5" id="0x96" type="uinteger" mandatory="1" minver="2" webm="0">Timecode of the referenced Block.</element>
+ <element name="CueRefCluster" level="5" id="0x97" type="uinteger" mandatory="1" webm="0">The <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">Position</a> of the Cluster containing the referenced Block.</element>
+ <element name="CueRefNumber" level="5" id="0x535F" type="uinteger" webm="0" default="1" range="not 0">Number of the referenced Block of Track X in the specified Cluster.</element>
+ <element name="CueRefCodecState" level="5" id="0xEB" type="uinteger" webm="0" default="0">The <a href="http://www.matroska.org/technical/specs/notes.html#Position_References">position</a> of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry.</element>
+ <element name="Attachments" level="1" id="0x1941A469" type="master" minver="1" webm="0">Contain attached files.</element>
+ <element name="AttachedFile" level="2" id="0x61A7" type="master" mandatory="1" multiple="1" minver="1" webm="0">An attached file.</element>
+ <element name="FileDescription" level="3" id="0x467E" type="utf-8" minver="1" webm="0">A human-friendly name for the attached file.</element>
+ <element name="FileName" level="3" id="0x466E" type="utf-8" mandatory="1" minver="1" webm="0">Filename of the attached file.</element>
+ <element name="FileMimeType" level="3" id="0x4660" type="string" mandatory="1" minver="1" webm="0">MIME type of the file.</element>
+ <element name="FileData" level="3" id="0x465C" type="binary" mandatory="1" minver="1" webm="0">The data of the file.</element>
+ <element name="FileUID" level="3" id="0x46AE" type="uinteger" mandatory="1" minver="1" webm="0" range="not 0">Unique ID representing the file, as random as possible.</element>
+ <element name="FileReferral" level="3" id="0x4675" type="binary" webm="0">A binary value that a track/codec can refer to when the attachment is needed.</element>
+ <element name="FileUsedStartTime" level="3" id="0x4661" type="uinteger" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/World_Fonts">DivX font extension</a></element>
+ <element name="FileUsedEndTime" level="3" id="0x4662" type="uinteger" divx="1"><a href="http://developer.divx.com/docs/divx_plus_hd/format_features/World_Fonts">DivX font extension</a></element>
+ <element name="Chapters" level="1" id="0x1043A770" type="master" minver="1" webm="1">A system to define basic menus and partition data. For more detailed information, look at the <a href="http://www.matroska.org/technical/specs/chapters/index.html">Chapters Explanation</a>.</element>
+ <element name="EditionEntry" level="2" id="0x45B9" type="master" mandatory="1" multiple="1" minver="1" webm="1">Contains all information about a segment edition.</element>
+ <element name="EditionUID" level="3" id="0x45BC" type="uinteger" minver="1" webm="0" range="not 0">A unique ID to identify the edition. It's useful for tagging an edition.</element>
+ <element name="EditionFlagHidden" level="3" id="0x45BD" type="uinteger" mandatory="1" minver="1" webm="0" default="0" range="0-1">If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks). (1 bit)</element>
+ <element name="EditionFlagDefault" level="3" id="0x45DB" type="uinteger" mandatory="1" minver="1" webm="0" default="0" range="0-1">If a flag is set (1) the edition should be used as the default one. (1 bit)</element>
+ <element name="EditionFlagOrdered" level="3" id="0x45DD" type="uinteger" minver="1" webm="0" default="0" range="0-1">Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)</element>
+ <element name="ChapterAtom" level="3" recursive="1" id="0xB6" type="master" mandatory="1" multiple="1" minver="1" webm="1">Contains the atom information to use as the chapter atom (apply to all tracks).</element>
+ <element name="ChapterUID" level="4" id="0x73C4" type="uinteger" mandatory="1" minver="1" webm="1" range="not 0">A unique ID to identify the Chapter.</element>
+ <element name="ChapterStringUID" level="4" id="0x5654" type="utf-8" mandatory="0" minver="3" webm="1">A unique string ID to identify the Chapter. Use for <a href="http://dev.w3.org/html5/webvtt/#webvtt-cue-identifier">WebVTT cue identifier storage</a>.</element>
+ <element name="ChapterTimeStart" level="4" id="0x91" type="uinteger" mandatory="1" minver="1" webm="1">Timecode of the start of Chapter (not scaled).</element>
+ <element name="ChapterTimeEnd" level="4" id="0x92" type="uinteger" minver="1" webm="0">Timecode of the end of Chapter (timecode excluded, not scaled).</element>
+ <element name="ChapterFlagHidden" level="4" id="0x98" type="uinteger" mandatory="1" minver="1" webm="0" default="0" range="0-1">If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks). (1 bit)</element>
+ <element name="ChapterFlagEnabled" level="4" id="0x4598" type="uinteger" mandatory="1" minver="1" webm="0" default="1" range="0-1">Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter. (1 bit)</element>
+ <element name="ChapterSegmentUID" level="4" id="0x6E67" type="binary" minver="1" webm="0" range="&gt;0" bytesize="16">A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.</element>
+ <element name="ChapterSegmentEditionUID" level="4" id="0x6EBC" type="uinteger" minver="1" webm="0" range="not 0">The EditionUID to play from the segment linked in ChapterSegmentUID.</element>
+ <element name="ChapterPhysicalEquiv" level="4" id="0x63C3" type="uinteger" minver="1" webm="0">Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see <a href="http://www.matroska.org/technical/specs/index.html#physical">complete list of values</a>.</element>
+ <element name="ChapterTrack" level="4" id="0x8F" type="master" minver="1" webm="0">List of tracks on which the chapter applies. If this element is not present, all tracks apply</element>
+ <element name="ChapterTrackNumber" level="5" id="0x89" type="uinteger" mandatory="1" multiple="1" minver="1" webm="0" range="not 0">UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks.</element>
+ <element name="ChapterDisplay" level="4" id="0x80" type="master" multiple="1" minver="1" webm="1">Contains all possible strings to use for the chapter display.</element>
+ <element name="ChapString" cppname="ChapterString" level="5" id="0x85" type="utf-8" mandatory="1" minver="1" webm="1">Contains the string to use as the chapter atom.</element>
+ <element name="ChapLanguage" cppname="ChapterLanguage" level="5" id="0x437C" type="string" mandatory="1" multiple="1" minver="1" webm="1" default="eng">The languages corresponding to the string, in the <a href="http://lcweb.loc.gov/standards/iso639-2/englangn.html#two">bibliographic ISO-639-2 form</a>.</element>
+ <element name="ChapCountry" cppname="ChapterCountry" level="5" id="0x437E" type="string" multiple="1" minver="1" webm="0">The countries corresponding to the string, same 2 octets as in <a href="http://www.iana.org/cctld/cctld-whois.htm">Internet domains</a>.</element>
+ <element name="ChapProcess" cppname="ChapterProcess" level="4" id="0x6944" type="master" multiple="1" minver="1" webm="0">Contains all the commands associated to the Atom.</element>
+ <element name="ChapProcessCodecID" cppname="ChapterProcessCodecID" level="5" id="0x6955" type="uinteger" mandatory="1" minver="1" webm="0" default="0">Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the <a href="http://www.matroska.org/technical/specs/chapters/index.html#dvd">DVD</a> command set is used. More codec IDs can be added later.</element>
+ <element name="ChapProcessPrivate" cppname="ChapterProcessPrivate" level="5" id="0x450D" type="binary" minver="1" webm="0">Some optional data attached to the ChapProcessCodecID information. <a href="http://www.matroska.org/technical/specs/chapters/index.html#dvd">For ChapProcessCodecID = 1</a>, it is the "DVD level" equivalent.</element>
+ <element name="ChapProcessCommand" cppname="ChapterProcessCommand" level="5" id="0x6911" type="master" multiple="1" minver="1" webm="0">Contains all the commands associated to the Atom.</element>
+ <element name="ChapProcessTime" cppname="ChapterProcessTime" level="6" id="0x6922" type="uinteger" mandatory="1" minver="1" webm="0">Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).</element>
+ <element name="ChapProcessData" cppname="ChapterProcessData" level="6" id="0x6933" type="binary" mandatory="1" minver="1" webm="0">Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. <a href="http://www.matroska.org/technical/specs/chapters/index.html#dvd">For ChapProcessCodecID = 1</a>, the data correspond to the binary DVD cell pre/post commands.</element>
+ <element name="Tags" level="1" id="0x1254C367" type="master" multiple="1" minver="1" webm="0">Element containing elements specific to Tracks/Chapters. A list of valid tags can be found <a href="http://www.matroska.org/technical/specs/tagging/index.html">here.</a></element>
+ <element name="Tag" level="2" id="0x7373" type="master" mandatory="1" multiple="1" minver="1" webm="0">Element containing elements specific to Tracks/Chapters.</element>
+ <element name="Targets" cppname="TagTargets" level="3" id="0x63C0" type="master" mandatory="1" minver="1" webm="0">Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment.</element>
+ <element name="TargetTypeValue" cppname="TagTargetTypeValue" level="4" id="0x68CA" type="uinteger" minver="1" webm="0" default="50">A number to indicate the logical level of the target (see <a href="http://www.matroska.org/technical/specs/tagging/index.html#targettypes">TargetType</a>).</element>
+ <element name="TargetType" cppname="TagTargetType" level="4" id="0x63CA" type="string" minver="1" webm="0">An <strong>informational</strong> string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see <a href="http://www.matroska.org/technical/specs/tagging/index.html#targettypes">TargetType</a>).</element>
+ <element name="TagTrackUID" level="4" id="0x63C5" type="uinteger" multiple="1" minver="1" webm="0" default="0">A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.</element>
+ <element name="TagEditionUID" level="4" id="0x63C9" type="uinteger" multiple="1" minver="1" webm="0" default="0">A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.</element>
+ <element name="TagChapterUID" level="4" id="0x63C4" type="uinteger" multiple="1" minver="1" webm="0" default="0">A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.</element>
+ <element name="TagAttachmentUID" level="4" id="0x63C6" type="uinteger" multiple="1" minver="1" webm="0" default="0">A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.</element>
+ <element name="SimpleTag" cppname="TagSimple" level="3" recursive="1" id="0x67C8" type="master" mandatory="1" multiple="1" minver="1" webm="0">Contains general information about the target.</element>
+ <element name="TagName" level="4" id="0x45A3" type="utf-8" mandatory="1" minver="1" webm="0">The name of the Tag that is going to be stored.</element>
+ <element name="TagLanguage" level="4" id="0x447A" type="string" mandatory="1" minver="1" webm="0" default="und">Specifies the language of the tag specified, in the <a href="http://www.matroska.org/technical/specs/index.html#languages">Matroska languages form</a>.</element>
+ <element name="TagDefault" level="4" id="0x4484" type="uinteger" mandatory="1" minver="1" webm="0" default="1" range="0-1">Indication to know if this is the default/original language to use for the given tag. (1 bit)</element>
+ <element name="TagString" level="4" id="0x4487" type="utf-8" minver="1" webm="0">The value of the Tag.</element>
+ <element name="TagBinary" level="4" id="0x4485" type="binary" minver="1" webm="0">The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.</element>
+</table>
10 enzyme/tests/__init__.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+from . import test_mkv, test_parsers
+import unittest
+
+
+suite = unittest.TestSuite([test_mkv.suite(), test_parsers.suite()])
+
+
+if __name__ == '__main__':
+ unittest.TextTestRunner().run(suite)
2,974 enzyme/tests/parsers/ebml/test1.mkv.yml
2,974 additions, 0 deletions not shown
23 enzyme/tests/test.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+from enzyme.mkv import MKV, MalformedMKVError