HOME » MP4Box Introduction
The multimedia packager available in GPAC is called MP4Box. It can be used for performing various manipulations on multimedia files like AVI, MPG, MPEG-2 TS, but mostly on ISO media files (e.g. MP4, 3GP).
For detailed information on MP4Box options, check the Command-line Help links.
In short, MP4Box can be used for:
- manipulating ISO files like MP4, 3GP: adding, removing, multiplexing audio, video and presentation data (including subtitles) from different sources and in different formats,
- encoding/decoding presentation languages like MPEG-4 XMT or W3C SVG into/from binary formats like MPEG-4 BIFS or LASeR,
- performing encryption of streams
- attaching metadata to individual streams or to the whole ISO file to produce MPEG-21 compliant or hybrid MPEG-4/MPEG-21 files
- editing/packaging of HEIF image files
- preparation of HTTP Adaptive Streaming content,
- packaging and tagging the result for streaming, download and playback on different devices (e.g. phones, tablets) or for different software (e.g. iTunes).
The command-line documentation available in this subsection is based on GPAC 0.9.0; this documentation is automatically generated from the source tree on a daily basis.
This page only lists very basic but common usage of MP4Box. For more information, check:
- the command-line documentation
- the GPAC test suite
MP4Box can be used to repackage existing content to compliant ISO Media Files (MP4, 3GP, 3G2, OMA DCF). Note however that MP4Box prior to 0.9.0 does NOT re-encode audio, video and still image content, external tools shall be used for this purpose. With MP4Box 0.9.0 or above, MP4Box can be used in combination with encoding filters to transcode the content.
Transforming a DivX file to an MP4 file:
MP4Box -add file.avi new_file.mp4
Adding a secondary audio track to the previous file:
MP4Box -add audio2.mp3 new_file.mp4
MP4Box can import only parts or specific media from an existing container. To get the supported media that can be imported from a container:
MP4Box -info file.avi MP4Box -info file.mpg MP4Box -info file.ts
To add a single media from a container:
MP4Box -add file.mpg#audio new_file.mp4
To add a specific duration of a media from a container:
MP4Box -add file.mpg#audio:dur=10 new_file.mp4
MP4Box can be used to prepare files for different delivery protocols, mainly HTTP downloading or RTP streaming.
To prepare a file for simple progressive HTTP download, the following instruction will interleave file data by chunks of 500 milliseconds in order to enable playback while downloading the file (HTTP FastStart):
MP4Box -inter 500 file.mp4
To prepare for RTP, the following instruction will create RTP hint tracks for the file. This enables classic streaming servers like DarwinStreamingServer or QuickTime Streaming Server to deliver the file through RTSP/RTP:
MP4Box -hint file.mp4
To prepare for adaptive streaming (MPEG-DASH), the following instruction will create the DASH manifest and associated files. For more information on DASH see this page:
MP4Box -dash 1000 file.mp4
MP4Box can be used to encode MPEG-4 scene descriptions BIFS and LASeR and to decode MPEG-4 scene descriptions BIFS and LASeR.
To encode an existing description:
MP4Box -mp4 scene.bt MP4Box -mp4 scene.xmt MP4Box -mp4 scene.wrl MP4Box -mp4 file.svg
Note that MP4Box will do its best to encode VRML/X3D to MPEG-4, but that not all tools from X3D or VRML extensions are supported in MPEG-4.
To decode an existing BIFS track to a BIFS Text format (VRML-like format)description:
MP4Box -bt file.mp4
To decode an existing BIFS track to XMT-A format:
MP4Box -xmt file.mp4
To decode an existing LASeR track to an XSR format (SAF+LASeR Markup Language) description:
MP4Box -lsr file.mp4
To decode the first sample of an existing LASeR track to an SVG file:
MP4Box -svg file.mp4