# MP4Box

Canonical URL: https://encode.wiki/tools/utilities/mp4box/
Content version: ca42e61ede0a24f789d7287a0001244ad22f4abf
Status: current
License: CC BY-SA 4.0
Checksum (SHA-256): 6f5450ef41dc1f4f41c1ad6ec35a9a0e44ef55c736b00a8a9deae68e6081d564

> **Repository:** [gpac/gpac](https://github.com/gpac/gpac). GPAC Ultramedia OSS for Video Streaming & Next-Gen Multimedia Transcoding, Packaging & Delivery. Latest release: [v26.07.0](https://github.com/gpac/gpac/releases/tag/v26.07.0), Jul 24, 2026. Last commit: Oct 7, 2026. License: LGPL-2.1. Stars: 3,312.

MP4Box is the command-line MP4 tool from [GPAC](https://gpac.io/), the open-source multimedia framework developed at Télécom Paris. It is to [MP4](/containers/mp4/) roughly what [mkvmerge](/tools/utilities/mkvtoolnix/) is to Matroska: it muxes elementary streams into MP4, edits tracks and metadata, concatenates and splits files, fragments them, and packages them for DASH and HLS streaming. It never re-encodes.

FFmpeg can do much of the basic muxing, but MP4Box gives finer control over the MP4 structure (brands, sample descriptions, edit lists, interleaving, fragmentation) and is a common choice for streaming packaging and for files that must pass strict MP4 validators or hardware players.

## Install it

GPAC publishes installers for Windows and macOS, Linux packages and nightly builds on [gpac.io/downloads](https://gpac.io/downloads/). It is also packaged as `gpac` by most Linux distributions and by Homebrew. MP4Box is installed together with the `gpac` command, which exposes the same framework as a filter pipeline.

## Inspect a file

```sh
MP4Box -info input.mp4
MP4Box -diso input.mp4
```

`-info` lists the brands, tracks, track IDs, codecs, durations and whether the file is fragmented. `-diso` dumps the complete box structure to `input_info.xml` for detailed debugging.

## Mux streams into MP4

```sh
MP4Box -add video.ivf -add audio.opus -new output.mp4
```

`-new` creates a new file. Without it, MP4Box **edits the named file in place**, adding to whatever it already contains.

Import options are appended to the file name with `:` and track selectors with `#`:

```sh
MP4Box -add video.h264:fps=24000/1001 -add audio.m4a:lang=ja -new output.mp4
MP4Box -add input.mkv#video -add input.mkv#audio -new output.mp4
```

Raw H.264/HEVC streams carry no timing, so give their frame rate with `:fps=`. `#video`, `#audio` and `#trackID=N` pick tracks from container inputs. Other useful import options are `:name=` (track title), `:delay=` (in milliseconds) and `:dur=` (import only part of the stream).

## Edit, join and extract

```sh
MP4Box -lang 2=ja input.mp4                  # set the language of track ID 2, in place
MP4Box -rem 3 input.mp4                      # remove track ID 3, in place
MP4Box -cat part1.mp4 -cat part2.mp4 -new joined.mp4
MP4Box -raw 1 input.mp4                      # extract track ID 1 as a raw stream
MP4Box -split 300 input.mp4                  # split into 300-second pieces at keyframes
```

Track IDs come from `-info` and usually start at 1. `-cat` requires the same codec and compatible settings in every part.

## Fragment and package for streaming

```sh
MP4Box -frag 2000 input.mp4 -out fragmented.mp4
MP4Box -dash 4000 -rap -profile onDemand -out dash/manifest.mpd input.mp4#video input.mp4#audio
MP4Box -dash 4000 -rap -out hls/master.m3u8 input.mp4#video input.mp4#audio
```

`-frag` writes a fragmented MP4 with fragments of about the given length in milliseconds. `-dash` sets the segment duration in milliseconds, and `-rap` starts every segment on a keyframe; the manifest type follows the `-out` extension (`.mpd` for DASH, `.m3u8` for HLS). The `onDemand` profile writes one file per track, indexed for byte-range requests.

Segments can only start on keyframes, so encode with a fixed keyframe interval that divides the segment length (for example a keyframe every 2 seconds for 4-second segments). For adaptive streaming with several renditions, all renditions need their keyframes at the same timestamps; pass every rendition to the same `-dash` command.

## Documentation

The [MP4Box documentation](https://wiki.gpac.io/MP4Box/MP4Box/) on the GPAC wiki covers every option; `MP4Box -h import`, `-h dash` and `-h dump` print the same sections offline.

## Related pages

- [MP4](/containers/mp4/) and [ISO Base Media File Format](/containers/isobmff/)
- [FFmpeg](/tools/utilities/ffmpeg/) and [MKVToolNix](/tools/utilities/mkvtoolnix/)
