MP4Box

Overview

The multimedia packager available in GPAC is called MP4Box.
It can be used for performing many manipulations on multimedia files like AVI, MPG, TS, but mostly on ISO media files (e.g. MP4, 3GP). A complete documentation is available here.

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,
  • for encoding/decoding presentation languages like MPEG-4 XMT or W3C SVG into/from binary formats like MPEG-4 BIFS or LASeR,
  • for performing encryption of streams
  • for attaching metadata to individual streams or to the whole ISO file to produce MPEG-21 compliant or hybrid MPEG-4/MPEG-21 files
  • for preparation of HTTP Adaptive Streaming content,
  • and packaging and tagging the result for streaming, download and playback on different devices (e.g. phones, tablets) or for different software (e.g. iTunes).

It is widely used: by the video community, by many cloud infrastructures for preparation of multimedia files for playback, especially for iTunes/iOS and PlayStation, and by academics.

Content Packaging

MP4Box can be used to repackage existing content to compliant ISO Media Files (MP4, 3GP, 3G2, OMA DCF). Note however that MP4Box does NOT re-encode audio, video and still image content, external tools shall be used for this purpose.

  • 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

Delivery Setup

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 post:
    MP4Box -dash 1000 file.mp4

Scene Transcoding

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