opus_in_isobmff.html 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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: August 28, 2018</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.8.1 (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 Identification
  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 Mapping
  33. <a href="#4.5.1">4.5.1</a> ISO Base Media native Channel Mapping
  34. <a href="#4.5.2">4.5.2</a> Composition on all active tracks (informative)
  35. <a href="#4.6">4.6</a> Basic Structure (informative)
  36. <a href="#4.6.1">4.6.2</a> Initial Movie
  37. <a href="#4.6.2">4.6.3</a> Movie Fragments
  38. <a href="#4.7">4.7</a> Example of Encapsulation (informative)
  39. <a href="#5">5</a> Author's Address
  40. <a name="1"></a>
  41. 1 Scope
  42. This specification specifies the fundamental way of the encapsulation of Opus coded bitstreams in ISO Base Media
  43. file format and its derivatives. The encapsulation of Opus coded bitstreams in QuickTime file format is outside
  44. the scope of this specification.
  45. <a name="2"></a>
  46. 2 Normative References
  47. [1] ISO/IEC 14496-12:2015 Corrected version
  48. Information technology — Coding of audio-visual objects — Part 12: ISO base media file format
  49. [2] RFC 6716
  50. Definition of the Opus Audio Codec
  51. [3] RFC 7845
  52. Ogg Encapsulation for the Opus Audio Codec
  53. <a name="3"></a>
  54. 3 Terms and Definitions
  55. 3.1 active track
  56. enabled track from the non-alternate group or selected track from alternate group
  57. 3.2 actual duration
  58. duration constructed from valid samples
  59. 3.3 edit
  60. entry in the Edit List Box
  61. 3.4 padded samples
  62. PCM samples after decoding Opus sample(s) which are not valid samples
  63. An Opus bitstream always contains them partially at the beginning and may contain them in part at the end, as
  64. long as not physically removed yet at the beginning and/or the end.
  65. 3.5 priming samples
  66. padded samples at the beginning of the Opus bitstream
  67. 3.6 sample-accurate
  68. for any PCM sample, a timestamp exactly matching its sampling timestamp is present in the media timeline.
  69. 3.7 valid samples
  70. PCM samples after decoding Opus sample(s) corresponding to input PCM samples
  71. <a name="4"></a>
  72. 4 Design Rules of Encapsulation
  73. 4.1 File Type Identification<a name="4.1"></a>
  74. This specification defines the brand 'Opus' to declare files are conformant to this specification. Additionally,
  75. files conformant to this specification shall contain at least one brand, which supports the requirements and the
  76. requirements described in this clause without contradiction, in the compatible brands list of the File Type Box.
  77. As an example, the minimal support of the encapsulation of Opus bitstreams in ISO Base Media file format requires
  78. the 'iso2' brand in the compatible brands list since support of roll groups is required.
  79. <a name="4.2"></a>
  80. 4.2 Overview of Track Structure
  81. This clause summarizes requirements of the encapsulation of Opus coded bitstream as media data in audio tracks
  82. in file formats compliant with the ISO Base Media File Format. The details are described in clauses after this
  83. clause.
  84. + The handler_type field in the Handler Reference Box shall be set to 'soun'.
  85. + The Media Information Box shall contain the Sound Media Header Box.
  86. + The codingname of the sample entry is 'Opus'.
  87. This specification does not define any encapsulation using MP4AudioSampleEntry with objectTypeIndication
  88. specified by the MPEG-4 Registration Authority (http://www.mp4ra.org/).
  89. See 4.3.1 Sample entry format to get the details about the sample entry.
  90. + The 'dOps' box is added to the sample entry to convey initializing information for the decoder.
  91. See 4.3.2 Opus Specific Box to get the details.
  92. + An Opus sample is exactly one Opus packet for each of different Opus bitstreams.
  93. See 4.3.3 Sample format to get the details.
  94. + Every Opus sample is a sync sample but requires pre-roll for every random access to get correct output.
  95. See 4.3.6 Random Access to get the details.
  96. <a name="4.3"></a>
  97. 4.3 Definitions of Opus sample
  98. 4.3.1 Sample entry format<a name="4.3.1"></a>
  99. For any track containing Opus bitstreams, at least one sample entry describing corresponding Opus bitstream
  100. shall be present inside the Sample Table Box. This version of the specification defines only one sample
  101. entry format named OpusSampleEntry whose codingname is 'Opus'. This sample entry includes exactly one Opus
  102. Specific Box defined in 4.3.2 as a mandatory box and indicates that Opus samples described by this sample
  103. entry are stored by the sample format described in 4.3.3.
  104. The syntax and semantics of the OpusSampleEntry is shown as follows.
  105. class OpusSampleEntry() extends AudioSampleEntry ('Opus') {
  106. OpusSpecificBox();
  107. }
  108. + channelcount:
  109. The channelcount field indicates the number of output channels and shall be set to the same value of
  110. the OutputChannelCount in the OpusDecoderConfigurationRecord. The value of this field may be used in
  111. the ChannelLayout if any as described in 4.5.1.
  112. + samplesize:
  113. The samplesize field shall be set to 16.
  114. + samplerate:
  115. The samplerate field shall be set to 48000&lt&lt16.
  116. + OpusSpecificBox
  117. This box contains initializing information for the decoder as defined in 4.3.2.
  118. 4.3.2 Opus Specific Box<a name="4.3.2"></a>
  119. Exactly one Opus Specific Box shall be present in each OpusSampleEntry.
  120. The Opus Specific Box contains an OpusDecoderConfigurationRecord which contains the Version field and
  121. this specification defines version 0 of this record. If incompatible changes occured in the fields after
  122. the Version field within the OpusDecoderConfigurationRecord in the future versions of this specification,
  123. another version will be defined.
  124. This box refers to Ogg Opus [3] at many parts but all the data are stored as big-endian format.
  125. The syntax and semantics of the Opus Specific Box is shown as follows.
  126. class ChannelMappingTable (unsigned int(8) OutputChannelCount) {
  127. unsigned int(8) StreamCount;
  128. unsigned int(8) CoupledCount;
  129. unsigned int(8 * OutputChannelCount) ChannelMapping;
  130. }
  131. aligned(8) class OpusDecoderConfigurationRecord {
  132. unsigned int(8) Version;
  133. unsigned int(8) OutputChannelCount;
  134. unsigned int(16) PreSkip;
  135. unsigned int(32) InputSampleRate;
  136. signed int(16) OutputGain;
  137. unsigned int(8) ChannelMappingFamily;
  138. if (ChannelMappingFamily != 0) {
  139. ChannelMappingTable(OutputChannelCount);
  140. }
  141. }
  142. class OpusSpecificBox extends Box('dOps') {
  143. OpusDecoderConfigurationRecord() OpusConfig;
  144. }
  145. + Version:
  146. The Version field shall be set to 0.
  147. In the future versions of this specification, this field may be set to other values. And without support
  148. of those values, the reader shall not read the fields after this within the OpusSpecificBox.
  149. + OutputChannelCount:
  150. The OutputChannelCount field shall be set to the same value as the *Output Channel Count* field in the
  151. identification header defined in Ogg Opus [3].
  152. + PreSkip:
  153. The PreSkip field indicates the number of the priming samples, that is, the number of samples at 48000 Hz
  154. to discard from the decoder output when starting playback. The value of the PreSkip field shall be at least
  155. 80 milliseconds' worth of PCM samples even when removing any number of Opus samples which may or may not
  156. contain the priming samples. The PreSkip field is not used for discarding the priming samples at the whole
  157. playback at all since it is informative only, and that task falls on the Edit List Box.
  158. + InputSampleRate:
  159. The InputSampleRate field shall be set to the same value as the *Input Sample Rate* field in the
  160. identification header defined in Ogg Opus [3].
  161. + OutputGain:
  162. The OutputGain field shall be set to the same value as the *Output Gain* field in the identification
  163. header define in Ogg Opus [3]. Note that the value is stored as 8.8 fixed-point.
  164. + ChannelMappingFamily:
  165. The ChannelMappingFamily field shall be set to the same value as the *Channel Mapping Family* field in
  166. the identification header defined in Ogg Opus [3]. Note that the value 255 may be used for an alternative
  167. to map channels by ISO Base Media native mapping. The details are described in 4.5.1.
  168. + StreamCount:
  169. The StreamCount field shall be set to the same value as the *Stream Count* field in the identification
  170. header defined in Ogg Opus [3].
  171. + CoupledCount:
  172. The CoupledCount field shall be set to the same value as the *Coupled Count* field in the identification
  173. header defined in Ogg Opus [3].
  174. + ChannelMapping:
  175. The ChannelMapping field shall be set to the same octet string as *Channel Mapping* field in the identi-
  176. fication header defined in Ogg Opus [3].
  177. 4.3.3 Sample format<a name="4.3.3"></a>
  178. An Opus sample is exactly one Opus packet for each of different Opus bitstreams. Due to support more than
  179. two channels, an Opus sample can contain frames from multiple Opus bitstreams but all Opus packets shall
  180. share with the total of frame sizes in a single Opus sample. The way of how to pack an Opus packet from
  181. each of Opus bitstreams into a single Opus sample follows Appendix B. in RFC 6716 [2].
  182. The endianness has nothing to do with any Opus sample since every Opus packet is processed byte-by-byte.
  183. In this specification, 'sample' means 'Opus sample' except for 'padded samples', 'priming samples', 'valid
  184. sample' and 'sample-accurate', i.e. 'sample' is 'sample' in the term defined in ISO/IEC 14496-12 [1].
  185. +-----------------------------------------+-------------------------------------+
  186. | Opus packet 0 (self-delimiting framing) | Opus packet 1 (undelimited framing) |
  187. +-----------------------------------------+-------------------------------------+
  188. |<---------------------------- the size of Opus sample ------------------------>|
  189. Figure 1 - Example structure of an Opus sample containing two Opus bitstreams
  190. 4.3.4 Duration of Opus sample<a name="4.3.4"></a>
  191. The duration of Opus sample is given by multiplying the total of frame sizes for a single Opus bitstream
  192. expressed in seconds by the value of the timescale field in the Media Header Box.
  193. Let's say an Opus sample consists of two Opus bitstreams, where the frame size of one bitstream is 40 milli-
  194. seconds and the frame size of another is 60 milliseconds, and the timescale field in the Media Header Box
  195. is set to 48000, then the duration of that Opus sample shall be 120 milliseconds since three 40 millisecond
  196. frame and two 60 millisecond frames shall be contained because of the maximum duration of Opus packet, 120
  197. milliseconds, and 5760 in the timescale indicated in the Media Header Box.
  198. To indicate the valid samples excluding the padded samples at the end of Opus bitstream, the duration of
  199. the last Opus sample of an Opus bitstream is given by multiplying the number of the valid samples by the
  200. value produced by dividing the value of the timescale field in the Media Header Box by 48000.
  201. 4.3.5 Sub-sample<a name="4.3.5"></a>
  202. The structure of the last Opus packet in an Opus sample is different from the others in the same Opus sample,
  203. and the others are invalid Opus packets as an Opus sample because of self-delimiting framing. To avoid
  204. complexities, sub-sample is not defined for Opus sample in this specification.
  205. 4.3.6 Random Access<a name="4.3.6"></a>
  206. This subclause describes the nature of the random access of Opus sample.
  207. 4.3.6.1 Random Access Point<a name="4.3.6.1"></a>
  208. All Opus samples can be independently decoded i.e. every Opus sample is a sync sample. Therefore, the
  209. Sync Sample Box shall not be present as long as there are no samples other than Opus samples in the same
  210. track. And the sample_is_non_sync_sample field for Opus samples shall be set to 0.
  211. 4.3.6.2 Pre-roll<a name="4.3.6.2"></a>
  212. Opus bitstream requires at least 80 millisecond pre-roll after each random access to get correct output.
  213. Pre-roll is indicated by the roll_distance field in AudioRollRecoveryEntry. AudioPreRollEntry shall not
  214. be used since every Opus sample is a sync sample in Opus bitstream. Note that roll_distance is expressed
  215. in sample units in a term of ISO Base Media File Format, and always takes negative values.
  216. For any track containing Opus bitstreams, at least one Sample Group Description Box and at least one
  217. Sample to Group Box within the Sample Table Box shall be present and these have the grouping_type field
  218. set to 'roll'. If any Opus sample is contained in a track fragment, the Sample to Group Box with the
  219. grouping_type field set to 'roll' shall be present for that track fragment.
  220. For the requirement of AudioRollRecoveryEntry, the compatible_brands field in the File Type Box shall
  221. contain at least one brand which requires support for roll groups.
  222. <a name="4.4"></a>
  223. 4.4 Trimming of Actual Duration
  224. Due to the priming samples (or the padding at the beginning) derived from the pre-roll for the startup and the
  225. padded samples at the end, we need trim from media to get the actual duration. An edit in the Edit List Box can
  226. achieve this demand, and the Edit Box and the Edit List Box shall be present.
  227. For sample-accurate trimming, proper timescale should be set to the timescale field in the Movie Header Box
  228. and the Media Header Box inside Track Box(es) for Opus bitstream. The timescale field in the Media Header Box is
  229. typically set to 48000. It is recommended that the timescale field in the Movie Header Box be set to the same
  230. value of the timescale field in the Media Header Box in order to avoid the rounding problem when specifying
  231. duration of edit if the timescales in all of the Media Header Boxes are set to the same value.
  232. For example, to indicate the actual duration of an Opus bitstream in a track with the timescale fields of both
  233. the Movie Header Box and the Media Header Box set to 48000, we would use the following edit:
  234. segment_duration = the number of the valid samples
  235. media_time = the number of the priming samples
  236. media_rate = 1 &lt&lt 16
  237. The Edit List Box is applied to whole movie including all movie fragments. Therefore, it is impossible to tell
  238. the actual duration in the case producing movie fragments on the fly such as live-streaming. In such cases,
  239. the duration of the last Opus sample may be helpful by setting zero to the segment_duration field since the
  240. value 0 represents implicit duration equal to the sum of the duration of all samples.
  241. <a name="4.5"></a>
  242. 4.5 Channel Mapping
  243. 4.5.1 ISO Base Media native Channel Mapping<a name="4.5.1"></a>
  244. ISO Base Media File Format, that is ISO/IEC 14496-12 [1], defines an extension ChannelLayout to the
  245. AudioSampleEntry, which conveys information of mapping channels to loudspeaker positions. The ChannelLayout
  246. enables to specify the channel layout more flexibly than the predefined layouts of the ChannelMappingFamily.
  247. To utilize the ChannelLayout for OpusSampleEntry, the ChannelMappingFamily field should be set to 255.
  248. Even when the ChannelMappingFamily field is set to another value, the assignment of each output channel to
  249. loudspeaker position specified by the ChannelMappingFamily would be changed as specified by the ChannelLayout.
  250. The procedure of the assignment is the following.
  251. 1. Decoded channels are mapped to output channels according to the ChannelMappingTable.
  252. 2. Output channels are mapped to loudspeaker positions according to the ChannelLayout.
  253. In this way, the parameters of the Opus Specific Box are processed before the ChannelLayout, and the
  254. ChannelLayout shall follow the Opus Specific Box.
  255. 4.5.2 Composition on all active tracks (informative)<a name="4.5.2"></a>
  256. By the application of alternate_group in the Track Header Box, whole audio channels in all active tracks from
  257. non-alternate group and/or different alternate group from each other are composited into the presentation. If
  258. an Opus sample consists of multiple Opus bitstreams, it can be splitted into individual Opus bitstreams and
  259. reconstructed into new Opus samples as long as every Opus bitstream has the same total duration in each Opus
  260. sample. This nature can be utilized to encapsulate a single Opus bitstream in each track without breaking the
  261. original channel layout.
  262. As an example, let's say there is a following track:
  263. OutputChannelCount = 6;
  264. StreamCount = 4;
  265. CoupledCount = 2;
  266. ChannelMapping = {0, 4, 1, 2, 3, 5}; // front left, front center, front right,
  267. // rear left, rear right, LFE
  268. Here, to couple front left to front right channels into the first stream, and couple rear left to rear right
  269. channels into the second stream, reordering is needed since coupled streams must precede any non-coupled
  270. stream. You extract the four Opus bitstreams from this track and you encapsulate two of the four into a track
  271. and the others into another track. The former track is as follows.
  272. OutputChannelCount = 6;
  273. StreamCount = 2;
  274. CoupledCount = 2;
  275. ChannelMapping = {0, 255, 1, 2, 3, 255}; // front left, front center, front right,
  276. // rear left, rear right, LFE
  277. And the latter track is as follows.
  278. OutputChannelCount = 6;
  279. StreamCount = 2;
  280. CoupledCount = 0;
  281. ChannelMapping = {255, 0, 255, 255, 255, 1}; // front left, front center, front right,
  282. // rear left, rear right, LFE
  283. In addition, the value of the alternate_group field in the both tracks is set to 0. As the result, the player
  284. may play as if channels with 255 are not present, and play the presentation constructed from the both tracks
  285. in the same channel layout as the one of the original track. Keep in mind that the way of the composition, i.e.
  286. the mixing for playback, is not defined here, and maybe different results could occur except for the channel
  287. layout of the original, depending on an implementation or the definition of a derived file format.
  288. Note that some derived file formats may specify the restriction to ignore alternate grouping. In the context
  289. of such file formats, this application is not available. This unavailability does not mean incompatibilities
  290. among file formats unless the restriction to the value of the alternate_group field is specified and brings
  291. about any conflict among their definitions.
  292. <a name="4.6"></a>
  293. 4.6 Basic Structure (informative)
  294. 4.6.1 Initial Movie<a name="4.6.1"></a>
  295. This subclause shows a basic structure of the Movie Box as follows:
  296. +----+----+----+----+----+----+----+----+------------------------------+
  297. |moov| | | | | | | | Movie Box |
  298. +----+----+----+----+----+----+----+----+------------------------------+
  299. | |mvhd| | | | | | | Movie Header Box |
  300. +----+----+----+----+----+----+----+----+------------------------------+
  301. | |trak| | | | | | | Track Box |
  302. +----+----+----+----+----+----+----+----+------------------------------+
  303. | | |tkhd| | | | | | Track Header Box |
  304. +----+----+----+----+----+----+----+----+------------------------------+
  305. | | |edts| | | | | | Edit Box |
  306. +----+----+----+----+----+----+----+----+------------------------------+
  307. | | | |elst| | | | | Edit List Box |
  308. +----+----+----+----+----+----+----+----+------------------------------+
  309. | | |mdia| | | | | | Media Box |
  310. +----+----+----+----+----+----+----+----+------------------------------+
  311. | | | |mdhd| | | | | Media Header Box |
  312. +----+----+----+----+----+----+----+----+------------------------------+
  313. | | | |hdlr| | | | | Handler Reference Box |
  314. +----+----+----+----+----+----+----+----+------------------------------+
  315. | | | |minf| | | | | Media Information Box |
  316. +----+----+----+----+----+----+----+----+------------------------------+
  317. | | | | |smhd| | | | Sound Media Header Box |
  318. +----+----+----+----+----+----+----+----+------------------------------+
  319. | | | | |dinf| | | | Data Information Box |
  320. +----+----+----+----+----+----+----+----+------------------------------+
  321. | | | | | |dref| | | Data Reference Box |
  322. +----+----+----+----+----+----+----+----+------------------------------+
  323. | | | | | | |url | | DataEntryUrlBox |
  324. +----+----+----+----+----+----+ or +----+------------------------------+
  325. | | | | | | |urn | | DataEntryUrnBox |
  326. +----+----+----+----+----+----+----+----+------------------------------+
  327. | | | | |stbl| | | | Sample Table |
  328. +----+----+----+----+----+----+----+----+------------------------------+
  329. | | | | | |stsd| | | Sample Description Box |
  330. +----+----+----+----+----+----+----+----+------------------------------+
  331. | | | | | | |Opus| | OpusSampleEntry |
  332. +----+----+----+----+----+----+----+----+------------------------------+
  333. | | | | | | | |dOps| Opus Specific Box |
  334. +----+----+----+----+----+----+----+----+------------------------------+
  335. | | | | | |stts| | | Decoding Time to Sample Box |
  336. +----+----+----+----+----+----+----+----+------------------------------+
  337. | | | | | |stsc| | | Sample To Chunk Box |
  338. +----+----+----+----+----+----+----+----+------------------------------+
  339. | | | | | |stsz| | | Sample Size Box |
  340. +----+----+----+----+----+ or +----+----+------------------------------+
  341. | | | | | |stz2| | | Compact Sample Size Box |
  342. +----+----+----+----+----+----+----+----+------------------------------+
  343. | | | | | |stco| | | Chunk Offset Box |
  344. +----+----+----+----+----+ or +----+----+------------------------------+
  345. | | | | | |co64| | | Chunk Large Offset Box |
  346. +----+----+----+----+----+----+----+----+------------------------------+
  347. | | | | | |sgpd| | | Sample Group Description Box |
  348. +----+----+----+----+----+----+----+----+------------------------------+
  349. | | | | | |sbgp| | | Sample to Group Box |
  350. +----+----+----+----+----+----+----+----+------------------------------+
  351. | |mvex|* | | | | | | Movie Extends Box |
  352. +----+----+----+----+----+----+----+----+------------------------------+
  353. | | |trex|* | | | | | Track Extends Box |
  354. +----+----+----+----+----+----+----+----+------------------------------+
  355. Figure 2 - Basic structure of Movie Box
  356. It is strongly recommended that the order of boxes should follow the above structure.
  357. Boxes marked with an asterisk (*) may be present.
  358. For most boxes listed above, the definition is as is defined in ISO/IEC 14496-12 [1]. The additional boxes
  359. and the additional requirements, restrictions and recommendations to the other boxes are described in this
  360. specification.
  361. 4.6.2 Movie Fragments<a name="4.6.2"></a>
  362. This subclause shows a basic structure of the Movie Fragment Box as follows:
  363. +----+----+----+----+----+----+----+----+------------------------------+
  364. |moof| | | | | | | | Movie Fragment Box |
  365. +----+----+----+----+----+----+----+----+------------------------------+
  366. | |mfhd| | | | | | | Movie Fragment Header Box |
  367. +----+----+----+----+----+----+----+----+------------------------------+
  368. | |traf| | | | | | | Track Fragment Box |
  369. +----+----+----+----+----+----+----+----+------------------------------+
  370. | | |tfhd| | | | | | Track Fragment Header Box |
  371. +----+----+----+----+----+----+----+----+------------------------------+
  372. | | |trun| | | | | | Track Fragment Run Box |
  373. +----+----+----+----+----+----+----+----+------------------------------+
  374. | | |sgpd|* | | | | | Sample Group Description Box |
  375. +----+----+----+----+----+----+----+----+------------------------------+
  376. | | |sbgp| | | | | | Sample to Group Box |
  377. +----+----+----+----+----+----+----+----+------------------------------+
  378. Figure 3 - Basic structure of Movie Fragment Box
  379. It is strongly recommended that the Movie Fragment Header Box and the Track Fragment Header Box be
  380. placed first in their container.
  381. Boxes marked with an asterisk (*) may be present.
  382. For the boxes listed above, the definition is as is defined in ISO/IEC 14496-12 [1].
  383. <a name="4.7"></a>
  384. 4.7 Example of Encapsulation (informative)
  385. [File]
  386. size = 17757
  387. [ftyp: File Type Box]
  388. position = 0
  389. size = 24
  390. major_brand = Opus : Opus audio coding
  391. minor_version = 0
  392. compatible_brands
  393. brand[0] = Opus : Opus audio coding
  394. brand[1] = iso2 : ISO Base Media file format version 2
  395. [moov: Movie Box]
  396. position = 24
  397. size = 757
  398. [mvhd: Movie Header Box]
  399. position = 32
  400. size = 108
  401. version = 0
  402. flags = 0x000000
  403. creation_time = UTC 2014/12/12, 18:41:19
  404. modification_time = UTC 2014/12/12, 18:41:19
  405. timescale = 48000
  406. duration = 33600 (00:00:00.700)
  407. rate = 1.000000
  408. volume = 1.000000
  409. reserved = 0x0000
  410. reserved = 0x00000000
  411. reserved = 0x00000000
  412. transformation matrix
  413. | a, b, u | | 1.000000, 0.000000, 0.000000 |
  414. | c, d, v | = | 0.000000, 1.000000, 0.000000 |
  415. | x, y, w | | 0.000000, 0.000000, 1.000000 |
  416. pre_defined = 0x00000000
  417. pre_defined = 0x00000000
  418. pre_defined = 0x00000000
  419. pre_defined = 0x00000000
  420. pre_defined = 0x00000000
  421. pre_defined = 0x00000000
  422. next_track_ID = 2
  423. [trak: Track Box]
  424. position = 140
  425. size = 608
  426. [tkhd: Track Header Box]
  427. position = 148
  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 = 240
  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 = 276
  466. size = 472
  467. [mdhd: Media Header Box]
  468. position = 284
  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 = 316
  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 = 367
  491. size = 381
  492. [smhd: Sound Media Header Box]
  493. position = 375
  494. size = 16
  495. version = 0
  496. flags = 0x000000
  497. balance = 0.000000
  498. reserved = 0x0000
  499. [dinf: Data Information Box]
  500. position = 391
  501. size = 36
  502. [dref: Data Reference Box]
  503. position = 399
  504. size = 28
  505. version = 0
  506. flags = 0x000000
  507. entry_count = 1
  508. [url : Data Entry Url Box]
  509. position = 415
  510. size = 12
  511. version = 0
  512. flags = 0x000001
  513. location = in the same file
  514. [stbl: Sample Table Box]
  515. position = 427
  516. size = 321
  517. [stsd: Sample Description Box]
  518. position = 435
  519. size = 79
  520. version = 0
  521. flags = 0x000000
  522. entry_count = 1
  523. [Opus: Audio Description]
  524. position = 451
  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 = 487
  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 = 514
  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 = 538
  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 = 578
  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 = 670
  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 = 694
  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 = 720
  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 = 748
  631. size = 8
  632. [mdat: Media Data Box]
  633. position = 756
  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>