opus_in_isobmff.html 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <link rel="stylesheet" type="text/css" href="opus_in_isobmff.css"/>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Encapsulation of Opus in ISO Base Media File Format</title>
  7. </head>
  8. <body bgcolor="0x333333" text="#60B0C0">
  9. <b><u>Encapsulation of Opus in ISO Base Media File Format</u></b><br>
  10. <font size="2">last updated: January 12, 2015</font><br>
  11. <br>
  12. <div class="normal_link pre frame_box">
  13. Encapsulation of Opus in ISO Base Media File Format
  14. Version 0.6.6 (incomplete)
  15. Table of Contents
  16. <a href="#1">1</a> Scope
  17. <a href="#2">2</a> Normative References
  18. <a href="#3">3</a> Terms and Definitions
  19. <a href="#4">4</a> Design Rules of Encapsulation
  20. <a href="#4.1">4.1</a> File Type Indentification
  21. <a href="#4.2">4.2</a> Overview of Track Structure
  22. <a href="#4.3">4.3</a> Definitions of Opus sample
  23. <a href="#4.3.1">4.3.1</a> Sample entry format
  24. <a href="#4.3.2">4.3.2</a> Opus Specific Box
  25. <a href="#4.3.3">4.3.3</a> Sample format
  26. <a href="#4.3.4">4.3.4</a> Duration of Opus sample
  27. <a href="#4.3.5">4.3.5</a> Sub-sample
  28. <a href="#4.3.6">4.3.6</a> Random Access
  29. <a href="#4.3.6.1">4.3.6.1</a> Random Access Point
  30. <a href="#4.3.6.2">4.3.6.2</a> Pre-roll
  31. <a href="#4.4">4.4</a> Trimming of Actual Duration
  32. <a href="#4.5">4.5</a> Channel Layout (informative)
  33. <a href="#4.6">4.6</a> Basic Structure (informative)
  34. <a href="#4.6.1">4.6.2</a> Initial Movie
  35. <a href="#4.6.2">4.6.3</a> Movie Fragments
  36. <a href="#4.7">4.7</a> Example of Encapsulation (informative)
  37. <a href="#5">5</a> Author's Address
  38. <a name="1"></a>
  39. 1 Scope
  40. This specification specifies the fundamental way of the encapsulation of Opus coded bitstreams in ISO Base Media
  41. file format and its derivatives. The encapsulation of Opus coded bitstreams in QuickTime file format is outside
  42. the scope of this specification.
  43. <a name="2"></a>
  44. 2 Normative References
  45. [1] ISO/IEC 14496-12:2012 Corrected version
  46. Information technology — Coding of audio-visual objects — Part 12: ISO base media file format
  47. [2] ISO/IEC 14496-12:2012/Amd.1:2013
  48. Information technology — Coding of audio-visual objects — Part 12: ISO base media file format
  49. AMENDMENT 1: Various enhancements including support for large metadata
  50. [3] RFC 6716
  51. Definition of the Opus Audio Codec
  52. [4] draft-ietf-codec-oggopus-06
  53. Ogg Encapsulation for the Opus Audio Codec
  54. <a name="3"></a>
  55. 3 Terms and Definitions
  56. 3.1 active track
  57. enabled track from the non-alternate group or selected track from alternate group
  58. 3.2 actual duration
  59. duration constructed from valid samples
  60. 3.3 edit
  61. entry in the Edit List Box
  62. 3.4 padded samples
  63. PCM samples after decoding Opus sample(s) which are not valid samples
  64. An Opus bitstream always contains them partially at the beginning and may contain them in part at the end, as
  65. long as not physically removed yet at the beginning and/or the end.
  66. 3.5 priming samples
  67. padded samples at the beginning of the Opus bitstream
  68. 3.6 sample-accurate
  69. for any PCM sample, a timestamp exactly matching its sampling timestamp is present in the media timeline.
  70. 3.7 valid samples
  71. PCM samples after decoding Opus sample(s) corresponding to input PCM samples
  72. <a name="4"></a>
  73. 4 Design Rules of Encapsulation
  74. 4.1 File Type Indentification<a name="4.1"></a>
  75. This specification does not define any brand to declare files are conformant to this specification. However,
  76. files conformant to this specification shall contain at least one brand, which supports the requirements and the
  77. requirements described in this clause without contradiction, in the compatible brands list of the File Type Box.
  78. As an example, the minimal support of the encapsulation of Opus bitstreams in ISO Base Media file format requires
  79. the 'iso2' brand in the compatible brands list since support of roll groups is required.
  80. <a name="4.2"></a>
  81. 4.2 Overview of Track Structure
  82. This clause summarizes requirements of the encapsulation of Opus coded bitstream as media data in audio tracks
  83. in file formats compliant with the ISO Base Media File Format. The details are described in clauses after this
  84. clause.
  85. + The handler_type field in the Handler Reference Box shall be set to 'soun'.
  86. + The Media Information Box shall contain the Sound Media Header Box.
  87. + The codingname of the sample entry is 'Opus'.
  88. This specification does not define any encapsulation using MP4AudioSampleEntry with objectTypeIndication
  89. specified by the MPEG-4 Registration Authority (http://www.mp4ra.org/).
  90. See 4.3.1 Sample entry format to get the details about the sample entry.
  91. + The 'dOps' box is added to the sample entry to convey initializing information for the decoder.
  92. See 4.3.2 Opus Specific Box to get the details.
  93. + An Opus sample is exactly one Opus packet for each of different Opus bitstreams.
  94. See 4.3.3 Sample format to get the details.
  95. + Every Opus sample is a sync sample but requires pre-roll for every random access to get correct output.
  96. See 4.3.6 Random Access to get the details.
  97. <a name="4.3"></a>
  98. 4.3 Definitions of Opus sample
  99. 4.3.1 Sample entry format<a name="4.3.1"></a>
  100. For any track containing Opus bitstreams, at least one sample entry describing corresponding Opus bitstream
  101. shall be present inside the Sample Table Box. This version of the specification defines only one sample
  102. entry format named OpusSampleEntry whose codingname is 'Opus'. This sample entry includes exactly one Opus
  103. Specific Box defined in 4.3.2 as a mandatory box and indicates that Opus samples described by this sample
  104. entry are stored by the sample format described in 4.3.3.
  105. The syntax and semantics of the OpusSampleEntry is shown as follows.
  106. class OpusSampleEntry() extends AudioSampleEntry ('Opus'){
  107. OpusSpecificBox();
  108. }
  109. + channelcount:
  110. The channelcount field shall be set to the sum of the total number of Opus bitstreams and the number
  111. of Opus bitstreams producing two channels. This value is indentical with (M+N), where M is the value of
  112. the *Coupled Stream Count* field and N is the value of the *Stream Count* field in the *Channel Mapping
  113. Table* in the identification header defined in Ogg Opus [4].
  114. + samplesize:
  115. The samplesize field shall be set to 16.
  116. + samplerate:
  117. The samplerate field shall be set to 48000&lt&lt16.
  118. + OpusSpecificBox
  119. This box contains initializing information for the decoder as defined in 4.3.2.
  120. 4.3.2 Opus Specific Box<a name="4.3.2"></a>
  121. Exactly one Opus Specific Box shall be present in each OpusSampleEntry.
  122. The Opus Specific Box contains the Version field and this specification defines version 0 of this box.
  123. If incompatible changes occured in the fields after the Version field within the OpusSpecificBox in the
  124. future versions of this specification, another version will be defined.
  125. This box refers to Ogg Opus [4] at many parts but all the data are stored as big-endian format.
  126. The syntax and semantics of the Opus Specific Box is shown as follows.
  127. class ChannelMappingTable (unsigned int(8) OutputChannelCount){
  128. unsigned int(8) StreamCount;
  129. unsigned int(8) CoupledCount;
  130. unsigned int(8 * OutputChannelCount) ChannelMapping;
  131. }
  132. aligned(8) class OpusSpecificBox extends Box('dOps'){
  133. unsigned int(8) Version;
  134. unsigned int(8) OutputChannelCount;
  135. unsigned int(16) PreSkip;
  136. unsigned int(32) InputSampleRate;
  137. signed int(16) OutputGain;
  138. unsigned int(8) ChannelMappingFamily;
  139. if (ChannelMappingFamily != 0) {
  140. ChannelMappingTable(OutputChannelCount);
  141. }
  142. }
  143. + Version:
  144. The Version field shall be set to 0.
  145. In the future versions of this specification, this field may be set to other values. And without support
  146. of those values, the reader shall not read the fields after this within the OpusSpecificBox.
  147. + OutputChannelCount:
  148. The OutputChannelCount field shall be set to the same value as the *Output Channel Count* field in the
  149. identification header defined in Ogg Opus [4].
  150. + PreSkip:
  151. The PreSkip field indicates the number of the priming samples, that is, the number of samples at 48000 Hz
  152. to discard from the decoder output when starting playback. The value of the PreSkip field could be zero
  153. when removing Opus samples containing the number of PCM samples equal to or more than of the priming
  154. samples. The PreSkip field is not used for discarding the priming samples at the whole playback at all
  155. since it is informative only, and that task falls on the Edit List Box.
  156. + InputSampleRate:
  157. The InputSampleRate field shall be set to the same value as the *Input Sample Rate* field in the
  158. identification header defined in Ogg Opus [4].
  159. + OutputGain:
  160. The OutputGain field shall be set to the same value as the *Output Gain* field in the identification
  161. header define in Ogg Opus [4]. Note that the value is stored as 8.8 fixed-point.
  162. + ChannelMappingFamily:
  163. The ChannelMappingFamily field shall be set to the same value as the *Channel Mapping Family* field in
  164. the identification header defined in Ogg Opus [4].
  165. + StreamCount:
  166. The StreamCount field shall be set to the same value as the *Stream Count* field in the identification
  167. header defined in Ogg Opus [4].
  168. + CoupledCount:
  169. The CoupledCount field shall be set to the same value as the *Coupled Count* field in the identification
  170. header defined in Ogg Opus [4].
  171. + ChannelMapping:
  172. The ChannelMapping field shall be set to the same octet string as *Channel Mapping* field in the identi-
  173. fication header defined in Ogg Opus [4].
  174. 4.3.3 Sample format<a name="4.3.3"></a>
  175. An Opus sample is exactly one Opus packet for each of different Opus bitstreams. Due to support more than
  176. two channels, an Opus sample can contain frames from multiple Opus bitstreams but all Opus packets shall
  177. share with the total of frame sizes in a single Opus sample. The way of how to pack an Opus packet from
  178. each of Opus bitstreams into a single Opus sample follows Appendix B. in RFC 6716 [3].
  179. The endianness has nothing to do with any Opus sample since every Opus packet is processed byte-by-byte.
  180. In this specification, 'sample' means 'Opus sample' except for 'padded samples', 'priming samples', 'valid
  181. sample' and 'sample-accurate', i.e. 'sample' is 'sample' in the term defined in ISO/IEC 14496-12 [1].
  182. +-----------------------------------------+-------------------------------------+
  183. | Opus packet 0 (self-delimiting framing) | Opus packet 1 (undelimited framing) |
  184. +-----------------------------------------+-------------------------------------+
  185. |<---------------------------- the size of Opus sample ------------------------>|
  186. Figure 1 - Example structure of an Opus sample containing two Opus bitstreams
  187. 4.3.4 Duration of Opus sample<a name="4.3.4"></a>
  188. The duration of Opus sample is given by multiplying the total of frame sizes for a single Opus bitstream
  189. expressed in seconds by the value of the timescale field in the Media Header Box.
  190. Let's say an Opus sample consists of two Opus bitstreams, where the frame size of one bitstream is 40 milli-
  191. seconds and the frame size of another is 60 milliseconds, and the timescale field in the Media Header Box
  192. is set to 48000, then the duration of that Opus sample shall be 120 milliseconds since three 40 millisecond
  193. frame and two 60 millisecond frames shall be contained because of the maximum duration of Opus packet, 120
  194. milliseconds, and 5760 in the timescale indicated in the Media Header Box.
  195. To indicate the valid samples excluding the padded samples at the end of Opus bitstream, the duration of
  196. the last Opus sample of an Opus bitstream is given by multiplying the number of the valid samples by the
  197. value produced by dividing the value of the timescale field in the Media Header Box by 48000.
  198. 4.3.5 Sub-sample<a name="4.3.5"></a>
  199. The structure of the last Opus packet in an Opus sample is different from the others in the same Opus sample,
  200. and the others are invalid Opus packets as an Opus sample because of self-delimiting framing. To avoid
  201. complexities, sub-sample is not defined for Opus sample in this specification.
  202. 4.3.6 Random Access<a name="4.3.6"></a>
  203. This subclause describes the nature of the random access of Opus sample.
  204. 4.3.6.1 Random Access Point<a name="4.3.6.1"></a>
  205. All Opus samples can be independently decoded i.e. every Opus sample is a sync sample. Therefore, the
  206. Sync Sample Box shall not be present as long as there are no samples other than Opus samples in the same
  207. track. And the sample_is_non_sync_sample field for Opus samples shall be set to 0.
  208. 4.3.6.2 Pre-roll<a name="4.3.6.2"></a>
  209. Opus bitstream requires at least 80 millisecond pre-roll after each random access to get correct output.
  210. Pre-roll is indicated by the roll_distance field in AudioRollRecoveryEntry. AudioPreRollEntry shall not
  211. be used since every Opus sample is a sync sample in Opus bitstream. Note that roll_distance is expressed
  212. in sample units in a term of ISO Base Media File Format, and always takes negative values.
  213. For any track containing Opus bitstreams, at least one Sample Group Description Box and at least one
  214. Sample to Group Box within the Sample Table Box shall be present and these have the grouping_type field
  215. set to 'roll'. If any Opus sample is contained in a track fragment, the Sample to Group Box with the
  216. grouping_type field set to 'roll' shall be present for that track fragment.
  217. For the requirement of AudioRollRecoveryEntry, the compatible_brands field in the File Type Box shall
  218. contain at least one brand which requires support for roll groups.
  219. <a name="4.4"></a>
  220. 4.4 Trimming of Actual Duration
  221. Due to the priming samples (or the padding at the beginning) derived from the pre-roll for the startup and the
  222. padded samples at the end, we need trim from media to get the actual duration. An edit in the Edit List Box can
  223. achieve this demand, and the Edit Box and the Edit List Box shall be present.
  224. For sample-accurate trimming, proper timescale should be set to the timescale field in the Movie Header Box
  225. and the Media Header Box inside Track Box(es) for Opus bitstream. The timescale field in the Media Header Box is
  226. typically set to 48000. It is recommended that the timescale field in the Movie Header Box be set to the same
  227. value of the timescale field in the Media Header Box in order to avoid the rounding problem when specifying
  228. duration of edit if the timescales in all of the Media Header Boxes are set to the same value.
  229. For example, to indicate the actual duration of an Opus bitstream in a track with the timescale fields of both
  230. the Movie Header Box and the Media Header Box set to 48000, we would use the following edit:
  231. segment_duration = the number of the valid samples
  232. media_time = the number of the priming samples
  233. media_rate = 1 &lt&lt 16
  234. The Edit List Box is applied to whole movie including all movie fragments. Therefore, it is impossible to tell
  235. the actual duration in the case producing movie fragments on the fly such as live-streaming. In such cases,
  236. the duration of the last Opus sample may be helpful by setting zero to the segment_duration field since the
  237. value 0 represents implicit duration equal to the sum of the duration of all samples.
  238. <a name="4.5"></a>
  239. 4.5 Channel Layout (informative)
  240. By the application of alternate_group in the Track Header Box, whole audio channels in all active tracks from
  241. non-alternate group and/or different alternate group from each other are composited into the presentation. If
  242. an Opus sample consists of multiple Opus bitstreams, it can be splitted into individual Opus bitstreams and
  243. reconstructed into new Opus samples as long as every Opus bitstream has the same total duration in each Opus
  244. sample. This nature can be utilized to encapsulate a single Opus bitstream in each track without breaking the
  245. original channel layout.
  246. As an example, let's say there is a following track:
  247. OutputChannelCount = 6;
  248. StreamCount = 4;
  249. CoupledCount = 2;
  250. ChannelMapping = {0, 4, 1, 2, 3, 5}; // front left, front center, front right, rear left, rear right, LFE
  251. Here, to couple front left to front right channels into the first stream, and couple rear left to rear right
  252. channels into the second stream, reordering is needed since coupled streams must precede any non-coupled stream.
  253. You extract the four Opus bitstreams from this track and you encapsulate two of the four into a track and the
  254. others into another track. The former track is as follows.
  255. OutputChannelCount = 6;
  256. StreamCount = 2;
  257. CoupledCount = 2;
  258. ChannelMapping = {0, 255, 1, 2, 3, 255}; // front left, front center, front right, rear left, rear right, LFE
  259. And the latter track is as follows.
  260. OutputChannelCount = 6;
  261. StreamCount = 2;
  262. CoupledCount = 0;
  263. ChannelMapping = {255, 0, 255, 255, 255, 1}; // front left, front center, front right, rear left, rear right, LFE
  264. In addition, the value of the alternate_group field in the both tracks is set to 0. As the result, the player
  265. may play as if channels with 255 are not present, and play the presentation constructed from the both tracks
  266. in the same channel layout as the one of the original track. Keep in mind that the way of the composition, i.e.
  267. the mixing for playback, is not defined here, and maybe different results could occur except for the channel
  268. layout of the original, depending on an implementation or the definition of a derived file format.
  269. Note that some derived file formats may specify the restriction to ignore alternate grouping. In the context of
  270. such file formats, this application is not available. This unavailability does not mean incompatibilities among
  271. file formats unless the restriction to the value of the alternate_group field is specified and brings about
  272. any conflict among their definitions.
  273. <a name="4.6"></a>
  274. 4.6 Basic Structure (informative)
  275. 4.6.1 Initial Movie<a name="4.6.1"></a>
  276. This subclause shows a basic structure of the Movie Box as follows:
  277. +----+----+----+----+----+----+----+----+------------------------------+
  278. |moov| | | | | | | | Movie Box |
  279. +----+----+----+----+----+----+----+----+------------------------------+
  280. | |mvhd| | | | | | | Movie Header Box |
  281. +----+----+----+----+----+----+----+----+------------------------------+
  282. | |trak| | | | | | | Track Box |
  283. +----+----+----+----+----+----+----+----+------------------------------+
  284. | | |tkhd| | | | | | Track Header Box |
  285. +----+----+----+----+----+----+----+----+------------------------------+
  286. | | |edts| | | | | | Edit Box |
  287. +----+----+----+----+----+----+----+----+------------------------------+
  288. | | | |elst| | | | | Edit List Box |
  289. +----+----+----+----+----+----+----+----+------------------------------+
  290. | | |mdia| | | | | | Media Box |
  291. +----+----+----+----+----+----+----+----+------------------------------+
  292. | | | |mdhd| | | | | Media Header Box |
  293. +----+----+----+----+----+----+----+----+------------------------------+
  294. | | | |hdlr| | | | | Handler Reference Box |
  295. +----+----+----+----+----+----+----+----+------------------------------+
  296. | | | |minf| | | | | Media Information Box |
  297. +----+----+----+----+----+----+----+----+------------------------------+
  298. | | | | |smhd| | | | Sound Media Header Box |
  299. +----+----+----+----+----+----+----+----+------------------------------+
  300. | | | | |dinf| | | | Data Information Box |
  301. +----+----+----+----+----+----+----+----+------------------------------+
  302. | | | | | |dref| | | Data Reference Box |
  303. +----+----+----+----+----+----+----+----+------------------------------+
  304. | | | | | | |url | | DataEntryUrlBox |
  305. +----+----+----+----+----+----+ or +----+------------------------------+
  306. | | | | | | |urn | | DataEntryUrnBox |
  307. +----+----+----+----+----+----+----+----+------------------------------+
  308. | | | | |stbl| | | | Sample Table |
  309. +----+----+----+----+----+----+----+----+------------------------------+
  310. | | | | | |stsd| | | Sample Description Box |
  311. +----+----+----+----+----+----+----+----+------------------------------+
  312. | | | | | | |Opus| | OpusSampleEntry |
  313. +----+----+----+----+----+----+----+----+------------------------------+
  314. | | | | | | | |dOps| Opus Specific Box |
  315. +----+----+----+----+----+----+----+----+------------------------------+
  316. | | | | | |stts| | | Decoding Time to Sample Box |
  317. +----+----+----+----+----+----+----+----+------------------------------+
  318. | | | | | |stsc| | | Sample To Chunk Box |
  319. +----+----+----+----+----+----+----+----+------------------------------+
  320. | | | | | |stsz| | | Sample Size Box |
  321. +----+----+----+----+----+ or +----+----+------------------------------+
  322. | | | | | |stz2| | | Compact Sample Size Box |
  323. +----+----+----+----+----+----+----+----+------------------------------+
  324. | | | | | |stco| | | Chunk Offset Box |
  325. +----+----+----+----+----+ or +----+----+------------------------------+
  326. | | | | | |co64| | | Chunk Large Offset Box |
  327. +----+----+----+----+----+----+----+----+------------------------------+
  328. | | | | | |sgpd| | | Sample Group Description Box |
  329. +----+----+----+----+----+----+----+----+------------------------------+
  330. | | | | | |sbgp| | | Sample to Group Box |
  331. +----+----+----+----+----+----+----+----+------------------------------+
  332. | |mvex|* | | | | | | Movie Extends Box |
  333. +----+----+----+----+----+----+----+----+------------------------------+
  334. | | |trex|* | | | | | Track Extends Box |
  335. +----+----+----+----+----+----+----+----+------------------------------+
  336. Figure 2 - Basic structure of Movie Box
  337. It is strongly recommended that the order of boxes should follow the above structure.
  338. Boxes marked with an asterisk (*) may be present.
  339. For most boxes listed above, the definition is as is defined in ISO/IEC 14496-12 [1]. The additional boxes
  340. and the additional requirements, restrictions and recommendations to the other boxes are described in this
  341. specification.
  342. 4.6.2 Movie Fragments<a name="4.6.2"></a>
  343. This subclause shows a basic structure of the Movie Fragment Box as follows:
  344. +----+----+----+----+----+----+----+----+------------------------------+
  345. |moof| | | | | | | | Movie Fragment Box |
  346. +----+----+----+----+----+----+----+----+------------------------------+
  347. | |mfhd| | | | | | | Movie Fragment Header Box |
  348. +----+----+----+----+----+----+----+----+------------------------------+
  349. | |traf| | | | | | | Track Fragment Box |
  350. +----+----+----+----+----+----+----+----+------------------------------+
  351. | | |tfhd| | | | | | Track Fragment Header Box |
  352. +----+----+----+----+----+----+----+----+------------------------------+
  353. | | |trun| | | | | | Track Fragment Run Box |
  354. +----+----+----+----+----+----+----+----+------------------------------+
  355. | | |sgpd|* | | | | | Sample Group Description Box |
  356. +----+----+----+----+----+----+----+----+------------------------------+
  357. | | |sbgp|* | | | | | Sample to Group Box |
  358. +----+----+----+----+----+----+----+----+------------------------------+
  359. Figure 3 - Basic structure of Movie Fragment Box
  360. It is strongly recommended that the Movie Fragment Header Box and the Track Fragment Header Box be
  361. placed first in their container.
  362. Boxes marked with an asterisk (*) may be present.
  363. For the boxes listed above, the definition is as is defined in ISO/IEC 14496-12 [1].
  364. <a name="4.7"></a>
  365. 4.7 Example of Encapsulation (informative)
  366. [File]
  367. size = 17790
  368. [ftyp: File Type Box]
  369. position = 0
  370. size = 24
  371. major_brand = mp42 : MP4 version 2
  372. minor_version = 0
  373. compatible_brands
  374. brand[0] = mp42 : MP4 version 2
  375. brand[1] = iso2 : ISO Base Media file format version 2
  376. [moov: Movie Box]
  377. position = 24
  378. size = 757
  379. [mvhd: Movie Header Box]
  380. position = 32
  381. size = 108
  382. version = 0
  383. flags = 0x000000
  384. creation_time = UTC 2014/12/12, 18:41:19
  385. modification_time = UTC 2014/12/12, 18:41:19
  386. timescale = 48000
  387. duration = 33600 (00:00:00.700)
  388. rate = 1.000000
  389. volume = 1.000000
  390. reserved = 0x0000
  391. reserved = 0x00000000
  392. reserved = 0x00000000
  393. transformation matrix
  394. | a, b, u | | 1.000000, 0.000000, 0.000000 |
  395. | c, d, v | = | 0.000000, 1.000000, 0.000000 |
  396. | x, y, w | | 0.000000, 0.000000, 1.000000 |
  397. pre_defined = 0x00000000
  398. pre_defined = 0x00000000
  399. pre_defined = 0x00000000
  400. pre_defined = 0x00000000
  401. pre_defined = 0x00000000
  402. pre_defined = 0x00000000
  403. next_track_ID = 2
  404. [iods: Object Descriptor Box]
  405. position = 140
  406. size = 33
  407. version = 0
  408. flags = 0x000000
  409. [tag = 0x10: MP4_IOD]
  410. expandableClassSize = 16
  411. ObjectDescriptorID = 1
  412. URL_Flag = 0
  413. includeInlineProfileLevelFlag = 0
  414. reserved = 0xf
  415. ODProfileLevelIndication = 0xff
  416. sceneProfileLevelIndication = 0xff
  417. audioProfileLevelIndication = 0xfe
  418. visualProfileLevelIndication = 0xff
  419. graphicsProfileLevelIndication = 0xff
  420. [tag = 0x0e: ES_ID_Inc]
  421. expandableClassSize = 4
  422. Track_ID = 1
  423. [trak: Track Box]
  424. position = 173
  425. size = 608
  426. [tkhd: Track Header Box]
  427. position = 181
  428. size = 92
  429. version = 0
  430. flags = 0x000007
  431. Track enabled
  432. Track in movie
  433. Track in preview
  434. creation_time = UTC 2014/12/12, 18:41:19
  435. modification_time = UTC 2014/12/12, 18:41:19
  436. track_ID = 1
  437. reserved = 0x00000000
  438. duration = 33600 (00:00:00.700)
  439. reserved = 0x00000000
  440. reserved = 0x00000000
  441. layer = 0
  442. alternate_group = 0
  443. volume = 1.000000
  444. reserved = 0x0000
  445. transformation matrix
  446. | a, b, u | | 1.000000, 0.000000, 0.000000 |
  447. | c, d, v | = | 0.000000, 1.000000, 0.000000 |
  448. | x, y, w | | 0.000000, 0.000000, 1.000000 |
  449. width = 0.000000
  450. height = 0.000000
  451. [edts: Edit Box]
  452. position = 273
  453. size = 36
  454. [elst: Edit List Box]
  455. position = 281
  456. size = 28
  457. version = 0
  458. flags = 0x000000
  459. entry_count = 1
  460. entry[0]
  461. segment_duration = 33600
  462. media_time = 312
  463. media_rate = 1.000000
  464. [mdia: Media Box]
  465. position = 309
  466. size = 472
  467. [mdhd: Media Header Box]
  468. position = 317
  469. size = 32
  470. version = 0
  471. flags = 0x000000
  472. creation_time = UTC 2014/12/12, 18:41:19
  473. modification_time = UTC 2014/12/12, 18:41:19
  474. timescale = 48000
  475. duration = 34560 (00:00:00.720)
  476. language = und
  477. pre_defined = 0x0000
  478. [hdlr: Handler Reference Box]
  479. position = 349
  480. size = 51
  481. version = 0
  482. flags = 0x000000
  483. pre_defined = 0x00000000
  484. handler_type = soun
  485. reserved = 0x00000000
  486. reserved = 0x00000000
  487. reserved = 0x00000000
  488. name = Xiph Audio Handler
  489. [minf: Media Information Box]
  490. position = 400
  491. size = 381
  492. [smhd: Sound Media Header Box]
  493. position = 408
  494. size = 16
  495. version = 0
  496. flags = 0x000000
  497. balance = 0.000000
  498. reserved = 0x0000
  499. [dinf: Data Information Box]
  500. position = 424
  501. size = 36
  502. [dref: Data Reference Box]
  503. position = 432
  504. size = 28
  505. version = 0
  506. flags = 0x000000
  507. entry_count = 1
  508. [url : Data Entry Url Box]
  509. position = 448
  510. size = 12
  511. version = 0
  512. flags = 0x000001
  513. location = in the same file
  514. [stbl: Sample Table Box]
  515. position = 460
  516. size = 321
  517. [stsd: Sample Description Box]
  518. position = 468
  519. size = 79
  520. version = 0
  521. flags = 0x000000
  522. entry_count = 1
  523. [Opus: Audio Description]
  524. position = 484
  525. size = 63
  526. reserved = 0x000000000000
  527. data_reference_index = 1
  528. reserved = 0x0000
  529. reserved = 0x0000
  530. reserved = 0x00000000
  531. channelcount = 6
  532. samplesize = 16
  533. pre_defined = 0
  534. reserved = 0
  535. samplerate = 48000.000000
  536. [dOps: Opus Specific Box]
  537. position = 520
  538. size = 27
  539. Version = 0
  540. OutputChannelCount = 6
  541. PreSkip = 312
  542. InputSampleRate = 48000
  543. OutputGain = 0
  544. ChannelMappingFamily = 1
  545. StreamCount = 4
  546. CoupledCount = 2
  547. ChannelMapping
  548. 0 -> 0: front left
  549. 1 -> 4: fron center
  550. 2 -> 1: front right
  551. 3 -> 2: side left
  552. 4 -> 3: side right
  553. 5 -> 5: rear center
  554. [stts: Decoding Time to Sample Box]
  555. position = 547
  556. size = 24
  557. version = 0
  558. flags = 0x000000
  559. entry_count = 1
  560. entry[0]
  561. sample_count = 18
  562. sample_delta = 1920
  563. [stsc: Sample To Chunk Box]
  564. position = 571
  565. size = 40
  566. version = 0
  567. flags = 0x000000
  568. entry_count = 2
  569. entry[0]
  570. first_chunk = 1
  571. samples_per_chunk = 13
  572. sample_description_index = 1
  573. entry[1]
  574. first_chunk = 2
  575. samples_per_chunk = 5
  576. sample_description_index = 1
  577. [stsz: Sample Size Box]
  578. position = 611
  579. size = 92
  580. version = 0
  581. flags = 0x000000
  582. sample_size = 0 (variable)
  583. sample_count = 18
  584. entry_size[0] = 977
  585. entry_size[1] = 938
  586. entry_size[2] = 939
  587. entry_size[3] = 938
  588. entry_size[4] = 934
  589. entry_size[5] = 945
  590. entry_size[6] = 948
  591. entry_size[7] = 956
  592. entry_size[8] = 955
  593. entry_size[9] = 930
  594. entry_size[10] = 933
  595. entry_size[11] = 934
  596. entry_size[12] = 972
  597. entry_size[13] = 977
  598. entry_size[14] = 958
  599. entry_size[15] = 949
  600. entry_size[16] = 962
  601. entry_size[17] = 848
  602. [stco: Chunk Offset Box]
  603. position = 703
  604. size = 24
  605. version = 0
  606. flags = 0x000000
  607. entry_count = 2
  608. chunk_offset[0] = 797
  609. chunk_offset[1] = 13096
  610. [sgpd: Sample Group Description Box]
  611. position = 727
  612. size = 26
  613. version = 1
  614. flags = 0x000000
  615. grouping_type = roll
  616. default_length = 2 (constant)
  617. entry_count = 1
  618. roll_distance[0] = -2
  619. [sbgp: Sample to Group Box]
  620. position = 753
  621. size = 28
  622. version = 0
  623. flags = 0x000000
  624. grouping_type = roll
  625. entry_count = 1
  626. entry[0]
  627. sample_count = 18
  628. group_description_index = 1
  629. [free: Free Space Box]
  630. position = 781
  631. size = 8
  632. [mdat: Media Data Box]
  633. position = 789
  634. size = 17001
  635. <a name="5"></a>
  636. 5 Authors' Address
  637. Yusuke Nakamura
  638. Email: muken.the.vfrmaniac |at| gmail.com
  639. </div>
  640. </body>
  641. </html>