LinuxCommandLibrary

mp4box

multimedia packager from the GPAC framework

TLDR

Add audio track to video

$ mp4box -add [audio.m4a] [video.mp4]
copy
Merge multiple MP4 files
$ mp4box -cat [file1.mp4] -cat [file2.mp4] -new [output.mp4]
copy
Extract specific track
$ mp4box -raw [1] [input.mp4]
copy
Add subtitles to video
$ mp4box -add [subtitles.srt] [video.mp4]
copy
Show file information
$ mp4box -info [file.mp4]
copy
Split file at intervals
$ mp4box -split [60] [input.mp4]
copy
Fragment for DASH streaming
$ mp4box -dash [4000] [input.mp4]
copy
Remove specific track
$ mp4box -rem [2] [input.mp4]
copy

SYNOPSIS

mp4box [-add file] [-cat file] [-info] [-dash duration] [options] file

DESCRIPTION

MP4Box is a multimedia packager from the GPAC framework. It manipulates MP4/ISO base media files - adding, removing, and editing tracks without re-encoding.
The tool handles muxing (combining audio, video, subtitles into one container), demuxing (extracting tracks), and file manipulation (splitting, concatenating, fragmenting). It supports numerous formats for import including H.264, H.265, AAC, MP3, SRT, and WebVTT.
DASH (Dynamic Adaptive Streaming over HTTP) support creates segmented files for adaptive streaming. This fragments content into small chunks with a manifest file, enabling players to switch quality based on bandwidth.
For streaming preparation, MP4Box can fragment files for HTTP progressive download, add hint tracks for RTSP streaming, and create initialization segments for live streaming workflows.
Metadata editing covers MP4 tags, chapter markers, and track properties. The tool can also encrypt content with various DRM schemes.

PARAMETERS

-add file[:opts]

Add media to file (import track).
-cat file
Concatenate file.
-rem trackID
Remove track by ID.
-raw trackID
Extract raw track data.
-info [trackID]
Display file or track information.
-new file
Create new output file.
-out file
Specify output file name.
-split seconds
Split file at time intervals.
-split-size KB
Split file by size.
-dash ms
Create DASH segments with duration in ms.
-frag ms
Fragment file with duration in ms.
-rap
Split only at random access points (keyframes).
-flat
Store in flat mode (non-interleaved).
-inter ms
Interleave with duration in ms.
-tmp dir
Use alternate temp directory.
-nosys
Remove system track info.
-fps rate
Force frame rate for raw imports.
-lang code
Set track language.

CAVEATS

Does not transcode - only repackages streams. Some operations modify files in place. Complex command syntax for advanced operations. DASH output requires proper web server configuration. Large files may need significant temporary storage. Some format combinations require specific codec compatibility.

HISTORY

MP4Box is part of GPAC, an open-source multimedia framework started by Jean Le Feuvre at ENST Paris around 2000. Originally focused on MPEG-4 research, GPAC expanded to support modern streaming formats. MP4Box became widely used for DASH content preparation and is relied upon by streaming services and content creators for media packaging.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community