Skip to content

Media Export and Dump

Extracting Options

MP4Box can be used to extract media tracks from MP4 files. If you need to convert these tracks however, please check the filters doc.

Options:
-raw (string): extract given track in raw format when supported. Use tkID:output=FileName to set output file name
-raws (string): extract each sample of the given track to a file. Use tkID:N to extract the Nth sample
-nhnt (int): extract given track to NHNT format
-nhml (string): extract given track to NHML format. Use tkID:full for full NHML dump with all packet properties
-webvtt-raw (string): extract given track as raw media in WebVTT as metadata. Use tkID:embedded to include media data in the WebVTT file
-single (int): extract given track to a new mp4 file
-six (int): extract given track as raw media in experimental XML streaming instructions
-mux (string): multiplex input file to given destination
-qcp (int): same as -raw but defaults to QCP file for EVRC/SMV
-saf: multiplex input file to SAF multiplex
-dvbhdemux: demultiplex DVB-H file into IP Datagrams sent on the network
-raw-layer (int): same as -raw but skips SVC/MVC/LHVC extractors when extracting
-diod: extract file IOD in raw format
-mpd (string): convert given HLS or smooth manifest (local or remote http) to MPD - options -url-template and -segment-timelinecan be used in this mode.
Note: This only provides basic conversion, for more advanced conversions, see gpac -h dasher

Warning: This is not compatible with other DASH options and does not convert associated segments

File Dumping

MP4Box has many dump functionalities, from simple track listing to more complete reporting of special tracks.

Options:
-std: dump/write to stdout and assume stdout is opened in binary mode
-stdb: dump/write to stdout and try to reopen stdout in binary mode
-tracks: print the number of tracks on stdout
-info (string): print movie info (no parameter) or track extended info with specified ID
-infon (string): print track info for given track number, 1 being the first track in the file
-infox: print movie and track extended info (same as -info Nfor each track)
-diso,-dmp4: dump IsoMedia file boxes in XML output
-dxml: dump IsoMedia file boxes and known track samples in XML output
-disox: dump IsoMedia file boxes except sample tables in XML output
-keep-ods: do not translate ISOM ODs and ESDs tags (debug purpose only)
-bt: dump scene to BT format
-xmt: dump scene to XMT format
-wrl: dump scene to VRML format
-x3d: dump scene to X3D XML format
-x3dv: dump scene to X3D VRML format
-lsr: dump scene to LASeR XML (XSR) format
-svg: dump scene to SVG
-drtp: dump rtp hint samples structure to XML output
-dts: print sample timing, size and position in file to text output
-dtsx: same as -dts but does not print offset
-dtsc: same as -dts but analyses each sample for duplicated dts/cts (slow !)
-dtsxc: same as -dtsc but does not print offset (slow !)
-dnal (int): print NAL sample info of given track
-dnalc (int): print NAL sample info of given track, adding CRC for each nal
-dnald (int): print NAL sample info of given track without DTS and CTS info
-dnalx (int): print NAL sample info of given track without DTS and CTS info and adding CRC for each nal
-sdp: dump SDP description of hinted file
-dsap (int): dump DASH SAP cues (see -cues) for a given track
-dsaps (int): same as -dsap but only print sample number
-dsapc (int): same as -dsap but only print CTS
-dsapd (int): same as -dsap but only print DTS
-dsapp (int): same as -dsap but only print presentation time
-dcr: dump ISMACryp samples structure to XML output
-dchunk: dump chunk info
-dump-cover: extract cover art
-dump-chap: extract chapter file as TTXT format
-dump-chap-ogg: extract chapter file as OGG format
-dump-chap-zoom: extract chapter file as zoom format
-dump-udta [tkID:]4cc: extract user data for the given 4CC. If tkID is given, dumps from UDTA of the given track ID, otherwise moov is used
-mergevtt: merge vtt cues while dumping
-ttxt (int): convert input subtitle to GPAC TTXT format if no parameter. Otherwise, dump given text track to GPAC TTXT format
-srt (int): convert input subtitle to SRT format if no parameter. Otherwise, dump given text track to SRT format
-nstat: generate node/field statistics for scene
-nstats: generate node/field statistics per Access Unit
-nstatx: generate node/field statistics for scene after each AU
-hash: generate SHA-1 Hash of the input file
-comp (string): replace with compressed version all top level box types given as parameter, formatted as orig_4cc_1=comp_4cc_1[,orig_4cc_2=comp_4cc_2]
-topcount (string): print to stdout the number of top-level boxes matching box types given as parameter, formatted as 4cc_1,4cc_2N
-topsize (string): print to stdout the number of bytes of top-level boxes matching types given as parameter, formatted as 4cc_1,4cc_2N or all for all boxes
-bin: convert input XML file using NHML bitstream syntax to binary
-mpd-rip: fetch MPD and segment to disk
-udp-write (string, default: IP[:port]): write input name to UDP (default port 2345)
-raw-cat (string): raw concatenation of given file with input file
-wget (string): fetch resource from http(s) URL
-dm2ts: dump timing of an input MPEG-2 TS stream sample timing
-check-xml: check XML output format for -dnal, -diso and -dxml options
-fuzz-chk: open file without probing and exit (for fuzz tests)

File splitting

MP4Box can split input files by size, duration or extract a given part of the file to new IsoMedia file(s).
This requires that at most one track in the input file has non random-access points (typically one video track at most).
Splitting will ignore all MPEG-4 Systems tracks and hint tracks, but will try to split private media tracks.
The input file must have enough random access points in order to be split. If this is not the case, you will have to re-encode the content.
You can add media to a file and split it in the same pass. In this case, the destination file (the one which would be obtained without splitting) will not be stored.

Time ranges are specified as follows:
S-E: S start and E end times, formatted as HH:MM:SS.ms, MM:SS.ms or time in seconds (int, double, fraction)
S:E: S start time and E end times in seconds (int, double, fraction). If E is prefixed with D, this sets E = S + time
* S:end or S:end-N: S start time in seconds (int, double), N number of seconds (int, double) before the end

MP4Box splitting runs a filter session using the reframer filter as follows:
- splitrange option of the reframer is always set
- source is demultiplexed with alltk option set
- start and end ranges are passed to xs and xe options of the reframer
- for -splitz, options xadjust and xround=after are enforced
- for -splitg, options xadjust and xround=before are enforced
- for -splitf, option xround=seek is enforced and propbe_refset if not specified at prompt
- for -splitx, option xround=closest and propbe_ref are enforced if not specified at prompt

The default output storage mode is to full interleave and will require a temp file for each output. This behavior can be modified using -flat, -newfs, -inter and -frag.
The output file name(s) can be specified using -out and templates (e.g. -out split$num%04d$.mp4 produces split0001.mp4, split0002.mp4, ...).
Multiple time ranges can be specified as a comma-separated list for -splitx, -splitz and -splitg.

-split (string): split in files of given max duration (float number) in seconds. A trailing unit can be specified:
M, m: duration is in minutes
H, h: size is in hours

-split-rap,-splitr (string): split in files at each new RAP
-split-size,-splits (string): split in files of given max size (integer number) in kilobytes. A trailing unit can be specified:
M, m: size is in megabytes
G, g: size is in gigabytes

-split-chunk,-splitx (string): extract the specified time range as follows:
- the start time is moved to the RAP sample closest to the specified start time
- the end time is kept as requested

-splitz (string): extract the specified time range so that ranges A:B and B:C share exactly the same boundary B:
- the start time is moved to the RAP sample at or after the specified start time
- the end time is moved to the frame preceding the RAP sample at or following the specified end time

-splitg (string): extract the specified time range as follows:
- the start time is moved to the RAP sample at or before the specified start time
- the end time is moved to the frame preceding the RAP sample at or following the specified end time

-splitf (string): extract the specified time range and insert edits such that the extracted output is exactly the specified range