Skip to content

mp4box gen opts

jeanlf edited this page Jan 21, 2020 · 23 revisions

HOME » MP4Box » General


MP4Box [option] input [option] [other_dash_inputs]

General Options

MP4Box is a multimedia packager, with a vast number of functionalities: conversion, splitting, hinting, dumping, DASH-ing, encryption and others.
MP4Box provides a large set of options, classified by categories (see -h). These options do not follow any particular ordering.
MP4Box performs in-place rewrite of IsoMedia files (the input file is overwritten). You can change this behaviour by using the -out option.
MP4Box stores by default the file with 0.5 second interleaving and meta-data (moov...) at the beginning, making it suitable for HTTP streaming. This may however takes longer to store the file, use -flat to change this behaviour.
MP4Box usually generates a temporary file when creating a new IsoMedia file. The location of this temporary file is OS-dependent, and it may happen that the drive/partition the temporary file is created on has not enough space or no write access. In such a case, you can specify a temporary file location with -tmp.
Note: Track operations identify tracks through their ID (usually refered as tkID in the help), not their order.
Option values:
Unless specified otherwise, an option of type integer expects a trackID value following it.An option of type boolean expects no following value.

File Splitting and Concatenation

MP4Box can split IsoMedia files by size, duration or extract a given part of the file to new IsoMedia file(s). This process requires that at most one track in the input file has non random-access points (typically one video track at most). This process will also ignore all MPEG-4 Systems tracks and hint tracks, but will try to split private media tracks.
Note: The input file must have enough random access points in order to be split. This may not be the case with some video files where only the very first sample of the video track is a key frame (many 3GP files with H263 video are recorded that way). In order to split such files you will have to use a real video editor and re-encode the content.
Note: 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 spliting) will not be stored.

-mem-track: enable memory tracker
-mem-track-stack: enable memory tracker with stack dumping
-p: use indicated profile for the global GPAC config. If not found, config file is created. If a file path is indicated, this will load profile from that file. Otherwise, this will create a directory of the specified name and store new config there. Reserved name 0 means a new profile, not stored to disk. Works using -p=NAME or -p NAME
-inter (number, default: 0.5): interleave file, producing track chunks with given duration in ms. A value of 0 disables interleaving
-old-inter (number): same as -inter but wihout drift correction
-tight (number): tight interleaving (sample based) of the file. This reduces disk seek operations but increases file size
-flat: store file with all media data first, non-interleaved. This speeds up writing time when creating new files
-frag (number): fragment file, producing track fragments of given duration in ms. This disables interleaving
-out (string): specify output file name. By default input file is overwritten
-tmp (string): specify directory for temporary file creation
-co64: force usage of 64-bit chunk offsets for ISOBMF files
-write-buffer (int): specify write buffer in bytes for ISOBMF files to reduce disk IO
-new: force creation of a new destination file
-newfs: force creation of a new destination file without temp file but interleaving support
-no-sys: remove all MPEG-4 Systems info except IOD, kept for profiles. This is the default when creating regular AV content
-no-iod: remove MPEG-4 InitialObjectDescriptor from file
-mfra: insert movie fragment random offset when fragmenting file (ignored in dash mode)
-isma: rewrite the file as an ISMA 1.0 file
-ismax: same as -isma and remove all clock references
-3gp: rewrite as 3GPP(2) file (no more MPEG-4 Systems Info), always enabled if destination file extension is .3gp, .3g2 or .3gpp. Some tracks may be removed in the process
-ipod: rewrite the file for iPod/old iTunes
-psp: rewrite the file for PSP devices
-brand (string): set major brand of file (ABCD) or brand with optional version (ABCD:v)
-ab (string): add given brand to file's alternate brand list
-rb (string): remove given brand to file's alternate brand list
-cprt (string): add copyright string to file
-chap (string): set chapter information from given file
-chapqt (string): set chapter information from given file, using QT signaling for text tracks
-set-track-id id1:id2 (string): change id of track with id1 to id2
-swap-track-id id1:id2 (string): swap the id between tracks with id1 to id2
-rem (int): remove given track from file
-rap (int): remove all non-RAP samples from given track
-refonly (int): remove all non-reference pictures from given track
-enable (int): enable given track
-disable (int): disable given track
-timescale (int, default: 600): set movie timescale to given value (ticks per second)
-lang [tkID=]LAN (string): set language. LAN is the BCP-47 code (eng, en-UK, ...). If no track ID is given, sets language to all tracks
-delay tkID=TIME (string): set track start delay in ms
-par tkID=PAR (string): set visual track pixel aspect ratio. PAR is:

  • N:D: set PAR to N:D in track, do not modify the bitstream
  • wN:D: set PAR to N:D in track and try to modify the bitstream
  • none: remove PAR info from track, do not modify the bitstream
  • auto: retrieve PAR info from bitstream and set it in track
  • force: force 1:1 PAR in track, do not modify the bitstream

-clap tkID=CLAP (string): set visual track clean aperture. CLAP is Wn,Wd,Hn,Hd,HOn,HOd,VOn,VOd or none

  • n, d: numerator, denominator
  • W, H, HO, VO: clap width, clap height, clap horizontal offset, clap vertical offset

-mx tkID=MX (string): set track matrix, with MX is M1:M2:M3:M4:M5:M6:M7:M8:M9 in 16.16 fixed point intergers or hexa
-name tkID=NAME (string): set track handler name to NAME (UTF-8 string)
-itags tag1[:tag2] (string): set iTunes tags to file, see -tag-list
-tag-list: print the set of supported iTunes tags
-split (string): split in files of given max duration. Set [-rap] to start each file at RAP
-split-size,-splits (string): split in files of given max size (in kb)
-split-rap,-splitr (string): split in files at each new RAP
-split-chunk,-splitx S:E (string): extract a new file from S (number of seconds) to E with E a number (in seconds), end or end-N, N being the desired number of seconds before the end
-splitz S:E (string): same as -split-chunk, but adjust the end time to be before the last RAP sample
-group-add (string): create a new grouping information in the file. Format is a colon-separated list of following options:

  • refTrack=ID: ID of the track used as a group reference. If not set, the track will belong to the same group as the previous trackID specified. If 0 or no previous track specified, a new alternate group will be created
  • switchID=ID: ID of the switch group to create. If 0, a new ID will be computed for you. If <0, disables SwitchGroup
  • criteria=string: list of space-separated 4CCs.
  • trackID=ID: ID of the track to add to this group.

Warning: Options modify state as they are parsed, trackID=1:criteria=lang:trackID=2 is different from criteria=lang:trackID=1:trackID=2

-group-rem-track (int): remove given track from its group
-group-rem (int): remove the track's group

-group-clean: remove all group information from all tracks

-ref id:XXXX:refID (string): add a reference of type 4CC from track ID to track refID

-keep-utc: keep UTC timing in the file after edit

-udta tkID:[OPTS] (string): set udta for given track or movie if tkID is 0. OPTS is a colon separated list of:

  • type=CODE: 4CC code of the UDTA (not needed for box= option)
  • box=FILE: location of the udta data, formatted as serialized boxes
  • box=base64,DATA: base64 encoded udta data, formatted as serialized boxes
  • src=FILE: location of the udta data (will be stored in a single box of type CODE)
  • src=base64,DATA: base64 encoded udta data (will be stored in a single box of type CODE)
    Note: If no source is set, UDTA of type CODE will be removed

-patch [tkID=]FILE (string): apply box patch described in FILE, for given trackID if set

-bo: freeze the order of boxes in input file

-init-seg (string): use the given file as an init segment for dumping or for encryption

-zmov: compress movie box according to ISOBMFF box compression

Encryption/Decryption Options

MP4Box supports encryption and decryption of ISMA, OMA and CENC content, see encryption filter gpac -h cecrypt.
It requires a specific XML file called CryptFile, whose syntax is available at

-crypt (string): encrypt the input file using the given CryptFile
-decrypt [drm_file] (string): decrypt the input file, potentially using the given CryptFile. If not given, will fail if the key management system is not supported
-set-kms (string): change ISMA/OMA KMS location for all tracks, or for a given one if ID=kms_uriis used

Help Options

-nodes: list supported MPEG4 nodes
-node (string): get given MPEG4 node syntax and QP infolist
-xnodes: list supported X3D nodes
-xnode (string): get given X3D node syntax
-snodes: list supported SVG nodes
-languages: list supported ISO 639 languages
-boxes: list all supported ISOBMF boxes and their syntax
-fstat: print filter session statistics (import/export/encrypt/decrypt/dashing)
-fgraph: print filter session graph (import/export/encrypt/decrypt/dashing)
-v: verbose mode
-version: get build version
--- INPUT: escape option if INPUT starts with - character

Clone this wiki locally
You can’t perform that action at this time.