Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cmlburnett/mkvxmlmaker

Python module that makes XML files for feeding mkvmerge
https://github.com/cmlburnett/mkvxmlmaker

Last synced: 3 months ago
JSON representation

Python module that makes XML files for feeding mkvmerge

Awesome Lists containing this project

README

        

mkvxmlmaker -- Makes XML files for mkvmerge

This module provides classes that can create XML files for feeding into mkvmerge.
The two XML files supported are for specifying chapters and tags.

MKVXML_chapter:

import mkvxmlmaker

c = mkvxmlmaker.MKVXML_chapter()
c.AddChapter('00:00:00.000', "Intro")
c.AddChapter('00:10:00.000', "Act 2")
c.AddChapter('00:20:00.000', "Act 3")
c.AddChapter('00:30:00.000', "Credits")

c.Save('./chapters.xml')

Produces the following XML:







1

00:00:00.000

Intro
eng




2

00:10:00.000

Act 2
eng




3

00:20:00.000

Act 3
eng




4

00:30:00.000

Credits
eng



MKVXML_tags

import mkvxmlmaker

c = mkvxmlmaker.MKVXML_tags()

t = c.NewTag()
t.TargetType = 'COLLECTION'
t.TargetTypeValue = 70
t['TITLE'] = 'ER'
t['TOTAL_PARTS'] = 15

t = c.NewTag()
t.TargetType = 'SEASON'
t.TargetTypeValue = 60
t['TITLE'] = 'Season 1'
t['PART_NUMBER'] = 1
t['TOTAL_PARTS'] = 25

t = c.NewTag()
t.TargetType = 'EPISODE'
t.TargetTypeValue = 50
t['TITLE'] = 'Make of Two Hearts'
t['PART_NUMBER'] = 16
t['WRITTEN_BY'] = 'Woodward, Lydia'
t['DIRECTED_BY'] = 'Leder, Mimi'
t['DESCRIPTION'] = 'Kayson pursues Lewis romantically. Ross and hathaway cope with a young Russian girl with AIDS whose adoptive mother abandons her. A humane policeman hauls in a dog he hit with his car.'

c.Save('./tags.xml')

Produces the following XML:






COLLECTION
70


TITLE
ER
eng


TOTAL_PARTS
15
eng




SEASON
60


PART_NUMBER
1
eng


TITLE
Season 1
eng


TOTAL_PARTS
25
eng




EPISODE
50


DESCRIPTION
Kayson pursues Lewis romantically. Ross and hathaway cope with a young Russian girl with AIDS whose adoptive mother abandons her. A humane policeman hauls in a dog he hit with his car.
eng


DIRECTED_BY
Leder, Mimi
eng


PART_NUMBER
16
eng


TITLE
Make of Two Hearts
eng


WRITTEN_BY
Woodward, Lydia
eng


These can then be used with mkvmerge to inject the data into the Matroska file:

mkvmerge -o out.mkv --chapters chapters.xml --global-tags tags.xml in.mkv

Some notes:
* Times provided to MKVXML_chapter.AddChapter are in absolute times, not lengths of the chapter
* Tags are applied globally (if --global-tags is used), hence no UIDs are provided
* AddAttachmentUID(), AddChapterUID(), AddEditionUID(), and AddTrackUID() are available to apply a tag to the specific UID

Links:
* https://mkvtoolnix.download/doc/mkvmerge.html
* http://matroska.org/technical/specs/tagging/index.html
* http://www.matroska.org/technical/specs/tagging/example-video.html