Chapter Specifications

This document is meant to explain how Chapters work in matroska, using examples.

Elements semantic

Element Name Level Class-ID Mand. Multi. Range Default Element Type Description
Chapters 1 [10][43][A7][70] - - - - sub-elements A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.
EditionEntry 2 [45][B9] * * - - sub-elements Contains all information about a segment edition.
EditionUID 3 [45][BC] - - > 0 - u-integer A unique ID to identify the edition. It's useful for tagging an edition.
EditionFlagHidden 3 [45][BD] * - 0-1 0 u-integer (1 bit) If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks).
EditionFlagDefault 3 [45][DB] * - 0-1 0 u-integer (1 bit) If a flag is set (1) the edition should be used as the default one.
EditionFlagOrdered 3 [45][DD] - - 0-1 0 u-integer (1 bit) Specify if the chapters can be defined multiple times and the order to play them is enforced.
ChapterAtom 3+ [B6] * * - - sub-elements Contains the atom information to use as the chapter atom (apply to all tracks).
ChapterUID4+[73][C4]*-> 0-u-integerA unique ID to identify the Chapter.
ChapterTimeStart 4+ [91] * - - - u-integer Timecode of the start of Chapter (not scaled).
ChapterTimeEnd 4+ [92] - - - - u-integer Timecode of the end of Chapter (timecode excluded, not scaled).
ChapterFlagHidden 4+ [98] * - 0-1 0 u-integer (1 bit) If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks).
ChapterFlagEnabled 4+ [45][98] * - 0-1 1 u-integer (1 bit) 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.
ChapterSegmentUID 4+ [6E][67] - - >0 - binary A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.
ChapterSegmentEditionUID 4+ [6E][BC] - - >> 0 - binary The edition to play from the segment linked in ChapterSegmentUID.
ChapterTrack 4+ [8F] - - - - sub-elements List of tracks on which the chapter applies. If this element is not present, all tracks apply
ChapterTrackNumber 5+ [89] * * > 0 - u-integer 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.
ChapterDisplay 4+ [80] - * - - sub-elements Contains all possible strings to use for the chapter display.
ChapString 5+ [85] * - - - UTF-8 Contains the string to use as the chapter atom.
ChapLanguage 5+ [43][7C] * * - eng string The languages corresponding to the string, in the bibliographic ISO-639-2 form.
ChapCountry 5+ [43][7E] - * - - string The countries corresponding to the string, same 2 octets as in Internet domains.
ChapProcess 4+ [69][44] - * - - sub-elements Contains all the commands associated to the Atom.
ChapProcessCodecID 5+ [69][55] * - - 0 u-integer Contains the type of the codec used for the processing. A value of 0 means native Matroska processing, a value of 1 means the DVD command set is used. More codec IDs can be added later.
ChapProcessPrivate 5+ [45][0D] - - - - binary Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent.
ChapProcessCommand 5+ [69][11] - * - - sub-elements Contains all the commands associated to the Atom.
ChapProcessTime 6+ [69][22] * - - - u-integer Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).
ChapProcessData 6+ [69][33] * - - - binary Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands.

Example 1 : basic chaptering

In this example a movie is split in different chapters. It could also just be an audio file (album) on which each track corresponds to a chapter.

  • 00000ms - 05000ms : Intro
  • 05000ms - 25000ms : Before the crime
  • 25000ms - 27500ms : The crime
  • 27500ms - 38000ms : The killer arrested
  • 38000ms - 43000ms : Credits

This would translate in the following matroska form :

Chapters
EditionEntry
 ChapterAtom
 ChapterUID0x123456
 ChapterTimeStart0 ns
 ChapterTimeEnd5,000,000 ns
 ChapterDisplay
 ChapterStringIntro
 ChapterLanguageeng
 ChapterAtom
 ChapterUID0x234567
 ChapterTimeStart5,000,000 ns
 ChapterTimeEnd25,000,000 ns
 ChapterDisplay
 ChapterStringBefore the crime
 ChapterLanguageeng
 ChapterDisplay
 ChapterStringAvant le crime
 ChapterLanguagefra
 ChapterAtom
 ChapterUID0x345678
 ChapterTimeStart25,000,000 ns
 ChapterTimeEnd27,500,000 ns
 ChapterDisplay
 ChapterStringThe crime
 ChapterLanguageeng
 ChapterDisplay
 ChapterStringLe crime
 ChapterLanguagefra
 ChapterAtom
 ChapterUID0x456789
 ChapterTimeStart27,500,000 ns
 ChapterTimeEnd38,000,000 ns
 ChapterDisplay
 ChapterStringAfter the crime
 ChapterLanguageeng
 ChapterDisplay
 ChapterStringAprès le crime
 ChapterLanguagefra
 ChapterAtom
 ChapterUID0x456789
 ChapterTimeStart38,000,000 ns
 ChapterTimeEnd43,000,000 ns
 ChapterDisplay
 ChapterStringCredits
 ChapterLanguageeng
 ChapterDisplay
 ChapterStringGénérique
 ChapterLanguagefra

Example 2 : nested chapters

In this example an (existing) album is split into different chapters, and one of them contain another splitting.

The Micronauts "Bleep To Bleep"

  • 00:00 - 12:28 : Baby Wants To Bleep/Rock
    • 00:00 - 04:38 : Baby wants to bleep (pt.1)
    • 04:38 - 07:12 : Baby wants to rock
    • 07:12 - 10:33 : Baby wants to bleep (pt.2)
    • 10:33 - 12:28 : Baby wants to bleep (pt.3)
  • 12:30 - 19:38 : Bleeper_O+2
  • 19:40 - 22:20 : Baby wants to bleep (pt.4)
  • 22:22 - 25:18 : Bleep to bleep
  • 25:20 - 33:35 : Baby wants to bleep (k)
  • 33:37 - 44:28 : Bleeper
Chapters
EditionEntry
 ChapterAtom
 ChapterUID0x654321
 ChapterTimeStart0 ns
 ChapterTimeEnd748,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to bleep/rock
 ChapterAtom
 ChapterUID0x123456
 ChapterTimeStart0 ns
 ChapterTimeEnd278,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to bleep (pt.1)
 ChapterAtom
 ChapterUID0x234567
 ChapterTimeStart278,000,000 ns
 ChapterTimeEnd432,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to rock
 ChapterAtom
 ChapterUID0x345678
 ChapterTimeStart432,000,000 ns
 ChapterTimeEnd633,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to bleep (pt.2)
 ChapterAtom
 ChapterUID0x456789
 ChapterTimeStart633,000,000 ns
 ChapterTimeEnd748,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to bleep (pt.3)
 ChapterAtom
 ChapterUID0x567890
 ChapterTimeStart750,000,000 ns
 ChapterTimeEnd1,178,500,000 ns
 ChapterDisplay
 ChapterStringBleeper_O+2
 ChapterAtom
 ChapterUID0x678901
 ChapterTimeStart1,180,500,000 ns
 ChapterTimeEnd1,340,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to bleep (pt.4)
 ChapterAtom
 ChapterUID0x789012
 ChapterTimeStart1,342,000,000 ns
 ChapterTimeEnd1,518,000,000 ns
 ChapterDisplay
 ChapterStringBleep to bleep
 ChapterAtom
 ChapterUID0x890123
 ChapterTimeStart1,520,000,000 ns
 ChapterTimeEnd2,015,000,000 ns
 ChapterDisplay
 ChapterStringBaby wants to bleep (k)
 ChapterAtom
 ChapterUID0x901234
 ChapterTimeStart2,017,000,000 ns
 ChapterTimeEnd2,668,000,000 ns
 ChapterDisplay
 ChapterStringBleeper

The menu features are handled like a chapter codec. That means each codec has a type, some private data and some data in the chapters.

The type of the menu system is defined by the ChapProcessCodecID parameter. For now only 2 values are supported : 0 matroska script, 1 menu borrowed from the DVD. The private data depend on the type of menu system (stored in ChapProcessPrivate), idem for the data in the chapters (stored in ChapProcessData).

Matroska Script (0)

This is the case when ChapProcessCodecID = 0. This is a script language build for Matroska purposes. The inspiration comes from ActionScript, javascript and other similar scripting languages. The commands are stored as text commands, in UTF-8. The syntax is C like, with commands spanned on many lines, each terminating with a ";". You can also include comments at the end of lines with "//" or comment many lines using "/* */". The scripts are stored in ChapProcessData. For the moment ChapProcessPrivate is not used.

The one and only command existing for the moment is GotoAndPlay( ChapterUID );. As the same suggests, it means that when this command is encountered, the playback should jump to the Chapter specified by the UID and play it.

DVD menu (1)

This is the case when ChapProcessCodecID = 1. Each level of a chapter corresponds to a logical level in the DVD system that is stored in the first octet of the ChapProcessPrivate. This DVD hierarchy is as follows:

ChapProcessPrivateDVD NameHierarchyCommands PossibleComment
0x30SSDVD domain-First Play, Video Manager, Video Title
0x2ALULanguage Unit-Contains only PGCs
0x28TTTitle-Contains only PGCs
0x20PGCProgram Group Chain (PGC)* 
0x18PGProgram 1Program 2Program 3- 
0x10PTTPart Of Title 1Part Of Title 2-Equivalent to the chapters on the sleeve.
0x08CNCell 1Cell 2Cell 3Cell 4Cell 5Cell 6- 

You can also recover wether a Segment is a Video Manager (VMG), Video Title Set (VTS) or Video Title Set Menu (VTSM) from the ChapterTranslateID element found in the Segment Info. This field uses 2 octets as follows:

  1. Domain Type: 0 for VMG, the domain number for VTS and VTSM
  2. Domain Value: 0 for VMG and VTSM, 1 for the VTS source.

For instance, the menu part from VTS_01_0.VOB would be coded [1,0] and the content part from VTS_02_3.VOB would be [2,1]. The VMG is always [0,0]

The following octets of ChapProcessPrivate are as follows:

Octet 1DVD NameFollowing Octets
0x30SSDomain name code (1: 0x00= First play, 0xC0= VMG, 0x40= VTSM, 0x80= VTS) + VTS(M) number (2)
0x2ALULanguage code (2) + Language extension (1)
0x28TTglobal Title number (2) + corresponding TTN of the VTS (1)
0x20PGCPGC number (2) + Playback Type (1) + Disabled User Operations (4)
0x18PGProgram number (2)
0x10PTTPTT-chapter number (1)
0x08CNCell number [VOB ID(2)][Cell ID(1)][Angle Num(1)]

If the level specified in ChapProcessPrivate is a PGC (0x20), there is an octet called the Playback Type, specifying the kind of PGC defined:

  • 0x00: entry only/basic PGC
  • 0x82: Title+Entry Menu (only found in the Video Manager domain)
  • 0x83: Root Menu (only found in the VTSM domain)
  • 0x84: Subpicture Menu (only found in the VTSM domain)
  • 0x85: Audio Menu (only found in the VTSM domain)
  • 0x86: Angle Menu (only found in the VTSM domain)
  • 0x87: Chapter Menu (only found in the VTSM domain)

The next 4 following octets correspond to the User Operation flags in the standard PGC. When a bit is set, the command should be disabled.

ChapProcessData contains the pre/post/cell commands in binary format as there are stored on a DVD. There is just an octet preceeding these data to specify the number of commands in the element. As follows: [# of commands(1)][command 1 (8)][command 2 (8)][command 3 (8)].

More information on the DVD commands and format on DVD-replica, where we got most of the info about it. You can also get information on DVD from the DVDinfo project.