# Multimedia File Interface library overview

The Multimedia File Interface (MMFI) library enables an application to merge audio and video media streams into a 3GP format file, and inversely, to split a 3GP format file into two separate media streams.

Using the MMFI library, a Video Access application can:

- Merge an NMS packetized format video stream and an NMS packetized format audio stream into a 3GP file, formatted in 3GPP Basic Profile or 3GPP Streaming Server Profile.

- Merge an NMS packetized format video stream and a raw AMR-NB IF2 audio stream into a 3GP file, formatted in 3GPP Basic Profile.

- Split a 3GP file into its constituent media streams, provided those streams are in the following format:

- - NMS packetized H.263 baseline bit video stream

  - NMS packetized H.263+ profile 3 bit video stream

  - NMS packetized H.264 baseline profile bit video stream

  - NMS packetized MPEG-4 simple profile bit video stream

  - NMS packetized AMR-NB IF2 bit audio stream

  - Raw AMR-NB IF2 bit audio stream

- Obtain format information from an existing 3GP file, such as contents and stream size.

- Create a 3GP file with a synchronization table that contains one synchronization point for every I-frame.

- Randomly access specific points in time within a file using the 3GP file's synchronization table.

- Create a 3GP file with hint tracks that contain instructions for packaging the audio and video tracks into a channel.

- Use a 3GP file's hint tracks to format audio and video media tracks according to the hint track information.

- Create a 3GP file with audio and video tracks synchronized using skew correction.

- Store SDP data to a 3GP file. Retrieve SDP data from a 3GP file.

Video Access merges audio and video streams into a 3GP file by formatting and storing the audio and video buffers resulting from adiRecordMMToMemory or adiRecordMMAsync calls. Video Access splits a file into audio and video streams by extracting the audio and video media tracks from a 3GP file and playing them with the adiPlayMMFromMemory or adiPlayMMAsync calls.

The MMFI library does not perform media transcoding during either merge or split operations.

## Input and output formats

There are three types of input or output formats used by the MMFI library to merge streams or split files:

- NMS packetized steam format (audio stream, video stream, or both)

Note: In the MMFI library header files, NMS packetized formats are referred to as native formats.

- Raw AMR-NB IF2 stream format (audio stream only)

- 3GP file format (including an audio stream, a video stream, or both)

The following table shows how the types of streams are utilized in a 3GP file.

This audio stream format | Plus this video stream format | Can be in this 3GP File Format
NMS packetized | NMS packetized | 3GPP Basic Profile or Streaming Server Profile
Raw AMR-NB IF2 | NMS packetized | 3GPP Basic Profile

### NMS packetized format

The NMS packetized format can be one of the following:

- H.263 baseline profile 0 or H.263+ profile 3, level 10 - 30 (QCIF, CIF) video elementary bit stream.

Video bit streams must conform to ITU-T Recommendation H.263 Annex X as defined in ITU-T Recommendation H.263 1998 and 2000 and 3GPP specifications TS.26.111 and TS.26.911.

- H.264 baseline profile level 1 – 1.2 (QCIF, CIF) video elementary bit stream formatted in the NMS-packetized proprietary format.

Video bit streams must conform to ITU-T Recommendation and H.264 and 3GPP specifications TS.26.111 and TS.26.911.

Note: For the H.264 video codec, raw video to 3GP format conversion is not supported.

- MPEG-4 simple profile level 0 - 3 (QCIF, CIF) video elementary bit stream formatted in the NMS packetized proprietary format.

The library expects an ISO/IEC 14496 simple profile level 0 - 3 bit stream. Time stamping and headers (in particular VOS/VO/VOL headers) are expected to be compliant with ISO/IEC 14496 and 3GPP TS 26.110 /TS 26.111. This information is needed in the correct format to allow the computation of parameters for the 3GP file formatting.

- AMR-NB IF2 elementary audio bit stream formatted in the NMS packetized proprietary format.

Audio bit streams must conform to ETSI/AMR, Adaptive Multi-Rate speech codec (AMR), in IF2 framing format, in any of the eight AMR compressed data rates.

The NMS packetized formats are supported by adiRecordMMToMemory, adiRecordMMAsync, adiPlayMMFromMemory, and adiPlayMMAsync.

### Raw AMR-NB IF2 format

This format consists of a raw AMR-NB IF2 elementary audio bit stream, as supported by adiRecordMMToMemory, adiRecordMMAsync, adiPlayMMFromMemory, and adiPlayMMAsync when using the audio transcoding configuration.

### 3GP format

The 3GP file format is compliant with the 3GPP TS 26.244 specification and conforms to 3GP file format Basic Profile or 3GPP Streaming Server Profile.

The 3GP file contains one video track (either H.263, H.264, or MPEG-4), one audio track (IF1 AMR NB audio elementary bit stream), or both. It can also contain hint tracks for one or both of the audio and video streams.

## 3GP merge and split processes

The 3GP merge and split processes are shown in the following illustration using NMS packetized format audio and video streams:

There are two types of format conversions:

- NMS packetized to 3GP

- 3GP to NMS packetized

### NMS packetized to 3GP format conversion

The following table shows how the MMFI converts data from NMS-packetized to 3GP format:

Step | Description
1 | Converts video NMS packetized format data into a raw video bit stream. Basic checking on NMS headers can optionally be performed.
2 | Converts audio NMS packetized format data into an AMR audio bit stream (AMR-NB IF2 format). Basic checking on NMS headers can optionally be performed. Note: The MMFI skips this step if the audio data is in raw format instead of NMS packetized format.
3 | Converts the IF2 AMR bit stream into IF1 AMR bit stream.
4 | Generates a .3gp file with 3GP meta data, the video elementary bit stream (MPEG-4, H.263, or H.264) and the IF1 AMR NB audio elementary bit stream. The 3GP formatting function does not perform any audio or video bit stream adaptation or transcoding. It only merges audio and video bit streams input into 3GP file format compliant with 3GPP TS 26.244.

The compressed media in a 3GP output file can be optionally limited in size and in duration. The maximum size is specified in bytes, and applies to the total size of the 3GP file or equivalent stream. The maximum time is specified in milliseconds.

### 3GP to NMS packetized format conversion

The following table shows how the Video Messaging Server Interface converts data from 3GP format to NMS packetized format:

Step | Description
1 | Extracts from the .3gp file the video elementary bit stream (H.263, H.264, or MPEG-4) and the IF1 AMR NB audio elementary bit stream.
2 | Converts the IF1 AMR bit stream into IF2 AMR bit stream.
3 | Converts the IF2 AMR audio bit stream into AMR audio data in NMS packetized format. Note: The MMFI skips this step if the audio data is to be converted to raw format instead of NMS packetized format.
4 | Converts the video bit stream into video data in NMS packetized format.