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