This section explains the application programming interface for the MP4 Demultiplexer library and how to use the library when creating user applications.
The library takes an MPEG-4 File Format, Version 1-compliant stream as input and gets information (such as the position and timestamp from the header data) for extracting H.264 video data and MPEG-4 AAC (AAC-LC, HE-AAC v1, or HE-AAC v2) audio elementary streams.
The package content of the MP4DMX library is as follows.
||MP4 Demultiplexer library.|
||Header files defining values including the API function names and parameter values.|
The library uses the following resources.
|Description||Required Size (Bytes)|
|MP4 Demultiplexer library.||256|
|Memory used by the library on the application side.|
|Each stts-Box, stsz-Box, ctts-Box.||When set to read in 32-KB partitions.||630|
|When set to no partitions.||1600; see Note|
To use this library, the user application must secure the memory area for the library to use. The amounts of memory used by the library are given below.
|Each stts-Box, stsz-Box, ctts-Box.||When set to read in 32-KB partitions.||256 + 630|
|When set to no partitions.||256 + 1600; see Note|
|Memory required for reading the MP4 file into user application memory.||32 or more.|
The MP4 Demultiplexer library provides functions to obtain the information needed to extract H.264 video and MPEG-4 AAC (AAC-LC, HE-AAC v1, HE-AAC v2) audio elementary streams from files conforming to MPEG-4 File Format, Version 1, according to the specifications given in the following sections.
The format for input streams is given below.
Streams that comply with the following formats can be accepted as input MP4 data.
In general, this library supports streams from files conforming to the MPEG-4 File Format, Version 1 specifications given above. The library does not support MPEG-4 File Format, Version 2, but does include some support for fragment files and 64-bit compatible file formats.
The input data structure is shown in the diagram below.
The MP4 Demultiplexer library outputs only offset positions from the beginning of an MP4 data file and the data size. Using this information, user applications can extract elementary stream (ES) data.
Applications can get the following ES data as output from the library.
Applications can get H.264 video data in the form of an H.264 elementary stream. The following H.264 elementary stream specifications are supported.
Applications can get audio data in the form of an MPEG-4 AAC (AAC-LC, HE-AAC v1, HE-AAC v2) elementary stream. The following MPEG-4 AAC specifications are supported.
The following diagram shows how data flows during demultiplexing.
Basic operation of the library comprises two processes for demultiplexing a stream: the ordinary process, which plays an MP4 data file back from the beginning, and the special process, which uses chunk offset information to fast-forward or rewind a bitstream. The ordinary process always starts playback at the beginning of a file regardless of seek points. Special process always starts playback from a seek point.
The ordinary process starts by parsing an MP4 data file's
MovieBox information to
get information about the MP4 file. Then execution is performed (
MP4DMXExecute), outputting information
that can be used to extract ES data to the callback routines, based on the parsed information. If the
data contains one or more
MovieFragmentBox elements, when all of the data in the current fragment
has been output, the next
MovieFragmentBox must be parsed by finding (
MP4DMXReadHeader) the header. Execution (
MP4DMXExecute) (or sample extraction) ends
when all information regarding elementary streams within the specified range in the MP4 file has
been passed to the callback routine and the callback routine has extracted the stream within the
The following diagram provides a flowchart of the ordinary process.
The following diagram shows the ordinary process when the MP4 data file contains one or more
The following diagram shows the process when boxes are split using a specified read size.
In addition to performing the steps used in the ordinary process, for the special process, the offset of
the seek point reached in current execution (get current position,
MP4DMXExecute) must be obtained
first. Then execution (or sample extraction) must be resumed using the offset value obtained. The following figure shows a flowchart that illustrates the special process.
User applications using this library can perform demultiplexing operations using the seven steps described below (initialization to library closing).
MovieFragmentRandomAccessOffsetBoxrecords within the MP4 data file.
The main purpose of the basic API is to handle the Box structures located directly under the root directory of an MP4 data file. The following utility functions are also provided for retrieving information and parsing lower-level Box structures.
PictureParameterSetdata from an
ESDBoxrecord for a specified track.
2014/07/30 Initial version.