mp4box
Package, inspect, and manipulate MP4 files
TLDR
Display information about an existing MP4 file
Add an SRT subtitle file into an MP4 file
Combine audio from one file and video from another
SYNOPSIS
mp4box [options] [input_file] [output_file]
mp4box -command [options] file1 ... fileN
PARAMETERS
-add file[:opt]
Adds a new media track from the specified file to the MP4. Options can include stream type, language, track ID, etc.
-cat file
Concatenates an existing MP4 file to the end of the current file.
-split time
Splits the input MP4 file into multiple files, each up to the specified time (in seconds).
-split-size size
Splits the input MP4 file into multiple files, each up to the specified size (in kilobytes).
-info
Displays detailed information about the MP4 file, including track details, codecs, and metadata.
-hint
Hints the MP4 file for streaming over RTP/RTSP, creating dedicated hint tracks for efficient delivery.
-raw trackID
Extracts the raw bitstream of a specified trackID from the MP4 file.
-rem trackID
Removes a specified trackID from the MP4 file.
-chap file
Adds chapters to the MP4 file from a specified file (e.g., a text file with chapter markers).
-dash file[:opt]
Generates MPEG-DASH (Dynamic Adaptive Streaming over HTTP) segments and manifest files for the given input MP4. Many options are available for DASH profiles, segment duration, etc.
-frag duration
Fragments the MP4 file into movie fragments (moof atoms) of a specified duration (in milliseconds). Useful for progressive download and streaming.
-lang trackID:lang
Sets the language code (e.g., 'eng', 'fre') for a specified trackID.
-clap w:h:x:y
Sets the clean aperture box dimensions for a video track, specifying width, height, X offset, and Y offset.
-par num:den
Sets the pixel aspect ratio (numerator:denominator) for a video track.
-set-MIME MIME_type
Sets the MIME type of the file. Useful for web servers.
DESCRIPTION
mp4box is a versatile command-line utility for manipulating and inspecting MP4 files, which conform to the ISO Base Media File Format. It is an integral part of the GPAC (Graph for Advanced Content) project, an open-source multimedia framework. mp4box allows users to perform a wide array of operations on MP4 files, including multiplexing raw audio/video streams (e.g., H.264, AAC) into an MP4 container, demultiplexing tracks, concatenating or splitting files, hinting files for streaming (e.g., RTP/RTSP), encrypting/decrypting tracks, and injecting metadata like chapters or pixel aspect ratios. It's widely used in multimedia development, streaming preparation, and content packaging workflows due to its robust feature set and adherence to industry standards.
CAVEATS
mp4box can be memory-intensive for large files or complex operations, potentially creating large temporary files. Its command-line syntax, particularly for advanced features like DASH or encryption, can be intricate and require careful attention to options and their order. Incorrect usage can lead to corrupted or unplayable files. It's recommended to test operations on copies of original files.
COMMON USE CASES
- Preparing content for web streaming: Using
-dash
or-frag
to create fragmented MP4s and DASH manifests. - Multiplexing media: Combining raw H.264 video and AAC audio into a single MP4 file.
- Extracting streams: Separating audio or video tracks from an existing MP4.
- Adding metadata: Injecting chapter markers, language codes, or copyright information.
- File inspection: Using
-info
to debug MP4 file structures or verify compliance.
INTEROPERABILITY
mp4box adheres to international standards for the ISO Base Media File Format, ensuring high interoperability with other tools and platforms that support MP4. This makes it a reliable choice for workflows where compatibility across different media players, web browsers, and streaming services is crucial.
HISTORY
mp4box is part of the GPAC project, which began development around 2000. It was created to provide a comprehensive toolset for working with MPEG-4 systems, including the ISO Base Media File Format (MP4). Over the years, it has evolved significantly, incorporating support for advanced features like MPEG-DASH, HEVC, and various DRM schemes, becoming a go-to tool for developers and content providers in the multimedia industry.