MP4Box(1)
๐ MP4Box(1) ๐
okay bestie, buckle UP โ this is the manual page for MP4Box, straight out of the GPAC fam. It's MP4Box(1), which means section 1 of the manual, and yes it's the command-line one, the one you actually run in your terminal like the main character you are. ๐
โจ NAME โจ
MP4Box โ the GPAC command-line media packager ๐ฆ
Likeโฆ it packs media. From the command line. That's the whole vibe. GPAC's little terminal bestie. ๐
โจ SYNOPSIS โจ
MP4Box [options] [file] [options]
Read it again, carefully, because the order is doing a thing:
MP4Boxโ the program itself, iconic, no notes ๐[options]โ options go first, because sure[file]โ then a file, if you feel like it[options]โ and then MORE OPTIONS after the file, because why would it be simple bestie ๐ญ
The square brackets mean optional, so technically MP4Box alone is valid syntax, which is very "I showed up to class with no supplies" energy. But fr fr, the options-after-the-file thing is real and you will absolutely use it, so don't come for me. ๐
โจ General Options โจ
okay bestie, so MP4Box is literally a multimedia packager with a vast number of functionalities: conversion, splitting, hinting, dumping, DASH-ing, encryption, transcoding and others. It's giving Swiss Army knife but for media. ๐ MP4Box provides a large set of options, classified by categories (see -h). These options do not follow any particular ordering. No cap.
By default, MP4Box rewrites the input file. You can change this behavior by using the out option. MP4Box stores by default the file with 0.5 second interleaving and metadata (moov ...) at the beginning, making it suitable for HTTP download-and-play. This may however takes longer to store the file, use flat to change this behavior. ๐
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. ๐๏ธ
Track identifier for track-based operations (usually referred to as tkID in the help) use the following syntax:
INT: target is track with ID INTnINT: target is track number INTaudio,video,text: target is first audio, video or text trackaudioN,videoN,textN: target is the Nth audio, video or text track, with N=1 being the first track of desired type
Option values: Unless specified otherwise, a track operation option of type integer expects a track identifier value following it. An option of type boolean expects no following value. โจ
-mem-trackโ enable memory tracker ๐ง-mem-track-stackโ enable memory tracker with stack dumping ๐-p(string) โ 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 name0means a new profile, not stored to disk. Works using-p=NAMEor-p NAME๐-inter(number, default: 0.5) โ interleave file, producing track chunks with given duration in ms. A value of0disables interleaving ๐-old-inter(number) โ same asinterbut without drift correction ๐ฐ๏ธ-tightโ 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 ISOBMFF output file name. By default input file is overwritten ๐-co64โ force usage of 64-bit chunk offsets for ISOBMF files ๐ข-newโ force creation of a new destination file ๐-newfsโ force creation of a new destination file without temp file but interleaving support ๐โจ-no-sys,-nosysโ 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 asismaand remove all clock references โฐ-3gpโ rewrite as 3GPP(2) file (no more MPEG-4 Systems Info), always enabled if destination file extension is.3gp,.3g2or.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. The following formats are supported (but cannot be mixed) in the chapter text file:- ZoomPlayer:
AddChapter(nb_frames,chapter name),AddChapterBySeconds(nb_sec,chapter name)andAddChapterByTime(h,m,s,chapter name)with 1 chapter per line - Time codes:
h:m:s chapter_name,h:m:s:ms chapter_nameandh:m:s.ms chapter_namewith 1 chapter per line - SMPTE codes:
h:m:s;nb_f/fps chapter_nameandh:m:s;nb_f chapter_namewith nb_f the number of frames and fps the framerate with 1 chapter per line - Common syntax:
CHAPTERX=h:m:s[:ms or .ms]on first line andCHAPTERXNAME=nameon next line (reverse order accepted)
- ZoomPlayer:
-chapqt(string) โ set chapter information from given file, using QT signaling for text tracks ๐-set-track-id tkID:id2โ change id of track to id2 ๐-swap-track-id tkID1:tkID1โ 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โ 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โ set track start delay (>0) or initial skip (<0) in ms or in fractional seconds (N/D) โณ-par tkID=PARโ set visual track pixel aspect ratio. PAR is:N:D: set PAR to N:D in track, do not modify the bitstreamwN:D: set PAR to N:D in track and try to modify the bitstreamnone: remove PAR info from track, do not modify the bitstreamauto: retrieve PAR info from bitstream and set it in trackforce: force 1:1 PAR in track, do not modify the bitstream
-clap tkID=CLAPโ set visual track clean aperture. CLAP isWn,Wd,Hn,Hd,HOn,HOd,VOn,VOdornonen, d: numerator, denominatorW, H, HO, VO: clap width, clap height, clap horizontal offset, clap vertical offset
-mx tkID=MXโ set track matrix, with MX isM1:M2:M3:M4:M5:M6:M7:M8:M9in 16.16 fixed point integers or hexa ๐ข-kind tkID=schemeURI=valueโ set kind for the track or for all tracks usingall=schemeURI=value๐ท๏ธ-kind-rem tkID=schemeURI=valueโ remove kind if given schemeID for the track or for all tracks withall=schemeURI=value๐๏ธ-name tkID=NAMEโ set track handler name to NAME (UTF-8 string) ๐-tags,-itags(string) โ set iTunes tags to file, see-h tags๐ต-group-add(string) โ create a new grouping information in the file. Format is a colon-separated list of following options:refTrack=ID: 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 createdswitchID=ID: ID of the switch group to create. If 0, a new ID will be computed for you. If <0, disables SwitchGroupcriteria=string: list of space-separated 4CCstrackID=ID: track to add to this group
Warning: Options modify state as they are parsed,trackID=1:criteria=lang:trackID=2is different fromcriteria=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 tkID:R4CC:refIDโ add a reference of type R4CC from track ID to track refID (remove track reference if refID is 0) ๐-keep-utcโ keep UTC timing in the file after edit ๐ฐ๏ธ-udta tkID:[OPTS]โ 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 boxesbox=base64,DATA: base64 encoded udta data, formatted as serialized boxessrc=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)str=STRING: use the given string as payload for the udta box
Note: If no source is set, UDTA of type CODE will be removed ๐ฆ
-patch [tkID=]FILEโ 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 or QT if mov extension ๐๏ธ-xmovโ same as zmov and wraps ftyp in otyp ๐๏ธโจ-edits tkID=EDITSโ set edit list. The following syntax is used (no separators between entries):r: removes all editseSTART: add empty edit with given start time. START can be- VAL: start time in seconds (int, double, fraction), media duration used as edit duration
- VAL-DUR: start time and duration in seconds (int, double, fraction)
eSTART,MEDIA[,RATE]: add regular edit with given start, media start time in seconds (int, double, fraction) and rate (fraction or INT)- Examples:
re0-5e5-3,4: remove edits, add empty edit at 0s for 5s, then add regular edit at 5s for 3s starting at 4s in media trackre0-4,0,0.5: remove edits, add single edit at 0s for 4s starting at 0s in media track and playing at speed 0.5
-moovpad(int) โ specify amount of padding to keep after moov box for later inplace editing - if 0, moov padding is disabled ๐งฉ-no-inplaceโ disable inplace rewrite ๐ซ-hdr(string) โ update HDR information based on given XML,noneremoves HDR info ๐-time [tkID=]DAY/MONTH/YEAR-H:M:Sโ set movie or track creation time ๐-mtime tkID=DAY/MONTH/YEAR-H:M:Sโ set media creation time ๐
โจ Extracting Options โจ
Okay so MP4Box can absolutely be used to extract media tracks from MP4 files ๐ bestie that's its whole thing. BUT โ and this is the important part โ if you need to convert those tracks after you pull them out, you gotta go check the filters doc instead. Different vibe, different doc. ๐ฆ
Options, bb:
-raw(string) โ extract the given track in raw format when that's supported. Wanna name your own output file? UsetkID:output=FileNameand it's yours. ๐-raws(string) โ extract each sample of the given track to its own file. UsetkID:Nto grab just the Nth sample. one sample, one file, no cap. โจ-nhnt(int) โ extract the given track into NHNT format.-nhml(string) โ extract the given track into NHML format. AddtkID:fullif you want the full NHML dump with literally every packet property in it. ๐-webvtt-raw(string) โ extract the given track as raw media in WebVTT as metadata. UsetkID:embeddedto shove the media data right into the WebVTT file. ๐ธ-single(int) โ extract the given track into a brand new mp4 file. glow up โจ-six(int) โ extract the given track as raw media in experimental XML streaming instructions. yes it says experimental. we move anyway. ๐-mux(string) โ multiplex the input file to the destination you give it. ๐ฌ-qcp(int) โ same as-rawbut it defaults to a QCP file for EVRC/SMV.-safโ multiplex the input file to SAF multiplex.-dvbhdemuxโ demultiplex a DVB-H file into IP Datagrams that get sent on the network. it's giving networking era ๐-raw-layer(int) โ same as-rawbut it skips the SVC/MVC/LHVC extractors while extracting.-diodโ extract the file IOD in raw format. iconic.-mpd(string) โ convert the given HLS or smooth manifest (local or remote http, both fine) to MPD โ options-url-templateand-segment-timelinecanbe used in this mode.
Note: this only provides basic conversion. For more advanced conversions, go see gpac -h dasher. ๐
Warning: this is not compatible with other DASH options and it does not convert associated segments. fr fr, heads up. ๐
๐ DASH Options ๐
Also see, bestie:
- the dasher
gpac -h dasherfilter documentation ๐ - [[DASH wiki|DASH-intro]] โจ
๐ฅ Specifying input files ๐ฅ
Input media files to dash can use the following modifiers โ think of them as little accessories you can clip onto your filename ๐ :
#trackID=N: only use the track ID N from the source file#N: only use the track ID N from the source file (this one's mapped to-tkid)#video: only use the first video track from the source file#audio: only use the first audio track from the source file#Prop=Value: add PID filtering using the same syntax as SID fragments (cfgpac -h doc):id=NAME: set the representation ID to NAME. The reserved valueNULLdisables the representation ID for multiplexed inputs. If you don't set it, a default value gets computed and all selected tracks from the source end up in the same output multiplex.:dur=VALUE: process VALUE seconds (fraction) from the media. If VALUE is longer than the media duration, the last sample duration gets extended.:period=NAME: set the representation's period to NAME. You can use multiple periods. Periods show up in the MPD in the exact same order you specified them with this option.:BaseURL=NAME: set the BaseURL. Set it multiple times for multiple BaseURLs.
Warning: this does not modify the generated files location (see segment template). ๐
:bandwidth=VALUE: set the representation's bandwidth to the value you give it:pdur=VALUE: sets the duration of the associated period to VALUE seconds (fraction) (it's an alias forperiod_duration:VALUE). This only gets used when no input media is specified (remote period insertion), e.g.:period=X:xlink=Z:pdur=Y:ddur=VALUE: override the target DASH segment duration to VALUE seconds (fraction) for this input (alias forduration:VALUE):xlink=VALUE: set the xlink value for the period containing this element. Only the xlink declared on the first rep of a period will be used.:asID=VALUE: set the AdaptationSet ID to VALUE (unsigned int):role=VALUE: set the role of this representation (cf DASH spec). Media with different roles belong to different adaptation sets.:desc_p=VALUE: add a descriptor at the Period level.:desc_as=VALUE: add a descriptor at the AdaptationSet level. Two input files with different values will land in different AdaptationSet elements.:desc_as_c=VALUE: add a descriptor at the AdaptationSet level. The value is ignored while creating AdaptationSet elements.:desc_rep=VALUE: add a descriptor at the Representation level. The value is ignored while creating AdaptationSet elements.:sscale: force the movie timescale to match the media timescale of the first track in the segment.:trackID=N: same as setting the fragment#trackID=@f1[:args][@fN:args][@@fK:args]: set a filter chain to insert between the source and the dasher. Each filter in the chain is formatted as a regular filter, see the filter docgpac -h doc. If you set several filters:- they'll be chained in the order you gave them if they're separated by a single
@ - a new filter chain gets created if they're separated by a double
@@. In this case, no representation ID is assigned to the source.
- they'll be chained in the order you gave them if they're separated by a single
Example:
source.mp4:@c=avc:b=1M@@c=avc:b=500k
This will load a filter chain with two encoders connected to the source and to the dasher. ๐
Example:
source.mp4:@c=avc:b=1M@c=avc:b=500k
This will load a filter chain with the second encoder connected to the output of the first (!!). yes that's a real exclamation, we're all fine ๐
Note: @f must be placed after all other options. like, after. all of them. ๐ซถ
Note: Descriptors value must be a properly formatted XML element(s), and the value is not checked. The syntax can use file@FILENAME to load content from a file. ๐ธ
โจ Options โจ
bestie this is the DASH options motherlode ๐ grab a boba, we're going through every single one, no skips, no cap.
-dashnumber โ creates a DASH out of your input files, where number is the segment duration in ms (for theonDemandprofile it's the subsegment duration instead) ๐ฌ-dash-livenumber โ generates a live DASH session using number as the segment duration in ms. bonus mode: doing-dash-live=Falso writes the live context out to F. MP4Box just stays in the live session until you pressqor something fatal happens ๐-ddbg-livenumber โ literally the same as-dash-livebut with no time regulation, purely for debug purposes ๐-fragnumber โ sets the fragment duration in ms. if you don't set it, it defaults to the DASH duration (so one fragment per segment, cute) โจ-outstring โ names your output MPD file, periodt ๐-profile,-dash-profilestring โ picks the target DASH profile and auto-sets default options so you actually conform to it. default isfullin static mode,livein dynamic mode (and yes, the old syntax using:liveinstead of.liveas the separator is still possible, legacy icon ๐). the defined values areonDemand,live,main,simple,full,hbbtv1.5.live,dashavc264.live,dashavc264.onDemand,dashif.ll-profile-extstring โ sets a list of profile extensions, the way DASH-IF and DVB use them. the string gets colon-concatenated with whatever profile you're using ๐-rapโ makes sure segments begin with random access points. heads up tho: segment durations might vary depending on the source encoding, it's giving chaotic but valid ๐-frag-rapโ same vibe but for all the fragments: every fragment begins with a random access point (durations might vary depending on the source encoding) ๐ฏ-segment-namestring โ sets the segment name for the segments you generate. if you don't set it (default), segments get concatenated in the output file โ except in the live profile where it'sdash_%%s. the supported replacement strings are:$Number[%%0Nd]$gets replaced by the segment number, possibly prefixed with0$RepresentationID$gets replaced by representation name$Time$gets replaced by segment start time$Bandwidth$gets replaced by representation bandwidth$Init=NAME$gets replaced byNAMEfor init segment, ignored otherwise$Index=NAME$gets replaced byNAMEfor index segments, ignored otherwise$Path=PATH$gets replaced byPATHwhen creating segments, ignored otherwise$SubNumber[%%0Nd]$gets replaced by the segment subnumber in segment sequences, possibly prefixed with0$Segment=NAME$gets replaced byNAMEfor media segments, ignored for init segments
-segment-extstring, default:m4sโ sets the segment extension.nullmeans no extension at all ๐ซ-init-segment-extstring, default:mp4โ sets the segment extension for init, index and bitstream switching segments.nullmeans no extension ๐-segment-timelineโ uses SegmentTimeline when generating segments ๐-segment-markerstring โ adds a box of the given type (a 4CC) at the end of each DASH segment ๐ท๏ธ-insert-utcโ inserts a UTC clock at the beginning of each ISOBMF segment โฐ-base-urlstring โ sets the Base url at MPD level. can be used several times.
Warning: this does not modify generated files location, so don't let it fool you bestie ๐ซ
-mpd-titlestring โ sets the MPD title ๐-mpd-sourcestring โ sets the MPD source ๐-mpd-info-urlstring โ sets the MPD info url ๐-cprtstring โ adds a copyright string to the MPD ยฉ๏ธ-dash-ctxstring โ store/restore DASH timing from the file you point at ๐พ-dynamicโ uses the dynamic MPD type instead of static ๐-last-dynamicโ same as-dynamicbut it closes the period (inserts thelmsgbrand if needed and updates the duration) ๐-mpd-durationnumber โ sets the duration in seconds of a live session (if it's0, you gotta use-mpd-refresh) โณ-mpd-refreshnumber โ sets the MPD update time in seconds ๐-time-shiftint โ sets the MPD time shift buffer depth in seconds.-1keeps all the files. default is0๐ฐ๏ธ-subdurnumber โ sets the max duration in ms of the input file to be dashed in LIVE or context mode. this does not change the segment duration, it just stops dashing once the segments produced exceed that duration. if there aren't enough samples to finish a segment, data is looped โ unless-no-loopis used, which triggers a period end ๐-run-forint โ runs the dash-live session for the given ms, then dips out ๐โโ๏ธ-min-bufferint โ sets the MPD min buffer time in ms ๐งบ-ast-offsetint โ sets the MPD AvailabilityStartTime offset in ms if positive, or the availabilityTimeOffset of each representation if negative โ๏ธ-dash-scaleint โ says the timing for-dash,-dash-live,-subdurand-fragis expressed in the given timescale (units per seconds) rather than ms ๐-mem-fragsโ fragmentation happens in memory rather than on disk before flushing to disk ๐ง-psshint โ sets the pssh store mode:v: initial movief: movie fragmentsm: MPDmv,vm: in initial movie and MPDmf,fm: in movie fragments and MPDn: remove PSSH from MPD, initial movie and movie fragments
-sample-groups-trafโ stores sample group descriptions in traf (duplicated for each traf). if not set, sample group descriptions go in the initial movie ๐ฆ-mvex-after-traksโ stores themvexbox after thetrakboxes within themoovbox. if not set,mvexgoes before ๐๏ธ-sdtp-trafint โ uses thesdtpbox in traf (Smooth-like):no: do not usesdtpsdtp: use thesdtpbox to indicate sample dependencies and do not write info in trun sample flagsboth: use thesdtpbox to indicate sample dependencies and also write info in trun sample flags
-no-cacheโ disables the file cache for dash inputs ๐ซ-no-loopโ disables looping content in live mode and uses period switch instead ๐-hlscโ inserts UTC in variant playlists for live HLS โฑ๏ธ-boundโ segmentation will always try to split before or at, but never after, the segment boundary โ๏ธ-closestโ segmentation will use the closest frame to the segment boundary (before or after) ๐ฏ-subsegs-per-sidx,-frags-per-sidxint โ sets the number of subsegments to be written in each SIDX box:0: a single SIDX box is used per segment-1: no SIDX box is used
-ssixโ enables SubsegmentIndexBox describing 2 ranges, first one frommoofto end of first I-frame, second one unmapped. this does not work with daisy chaining mode enabled โ ๏ธ-url-templateโ uses SegmentTemplate instead of explicit sources in segments. ignored if segments are stored in the output file ๐-url-template-simโ uses SegmentTemplate simulation while converting HLS to MPD ๐งช-daisy-chainโ uses daisy-chain SIDX instead of hierarchical. ignored if frags/sidx is0โ๏ธ-single-segmentโ uses a single segment for the whole file (OnDemand profile) 1๏ธโฃ-single-fileโ uses a single file for the whole file (default) ๐-bs-switchingstring, default:inband, values:inband|merge|multi|no|singleโ sets the bitstream switching mode:inband: use inband param set and a single init segmentmerge: try to merge param sets in a single sample description, fallback tonomulti: use several sample description, one per qualityno: use one init segment per qualitypps: use out of band VPS,SPS,DCI, inband for PPS,APS and a single init segmentsingle: to test with single input
-moof-snint โ sets the sequence number of the first moof to the given value ๐ข-tfdtint โ sets the TFDT of the first traf to the given value in SCALE units (cf-dash-scale) โฒ๏ธ-no-frags-defaultโ disables default fragments flags in trex (required by some dash-if profiles and CMAF/smooth streaming compatibility) ๐ง-single-trafโ uses a single track fragment per moof (smooth streaming and derived specs may require this) 1๏ธโฃ-tfdt-trafโ uses a tfdt per track fragment (when-single-trafis used) โฒ๏ธ-dash-ts-progint โ program_number to be considered in case of an MPTS input file ๐บ-frag-rtโ when using fragments in live mode, flush fragments according to their timing โฑ๏ธ-cp-locationstring โ sets the ContentProtection element location:as: sets ContentProtection in the AdaptationSet elementrep: sets ContentProtection in the Representation elementboth: sets ContentProtection in both elements
-start-datestring โ for live mode, sets the start date (asxs:date, e.g.YYYY-MM-DDTHH:MM:SSZ). default is current UTC.
Warning: do not use with multiple periods, nor when DASH duration is not a multiple of GOP size ๐ญ
-cuesstring โ ignores dash duration and segments according to cue times in the given XML file (seetests/media/dash_cuesfor examples) ๐ฏ-strict-cuesโ throws an error if something is wrong while parsing cues or applying cue-based segmentation ๐ฅ-merge-last-segโ merges the last segment if it's shorter than half the target duration ๐ค
๐ File splitting โ๏ธ
okay bestie, this is the glow-up section โ MP4Box can split your input files by size, by duration, or straight-up extract a given part of the file into new IsoMedia file(s). ๐
The catch? This needs at most one track in the input file to have non random-access points (so like, typically one video track at most). Fr fr.
Splitting will ignore all MPEG-4 Systems tracks and hint tracks, but it will try to split private media tracks. She's inclusive like that. ๐ซถ
Your input file also needs enough random access points to actually be splittable. If notโฆ ๐ญ you will have to re-encode the content. No cap.
Oh and you can add media to a file and split it in the same pass! Iconic. But heads up: in this case, the destination file (the one which would be obtained without splitting) will not be stored. It's giving "trust the process".
Time ranges are specified as follows:
S-EโSstart andEend times, formatted asHH:MM:SS.ms,MM:SS.msor time in seconds (int, double, fraction)S:EโSstart time andEend times in seconds (int, double, fraction). IfEis prefixed withD, this setsE = S + timeS:endorS:end-NโSstart time in seconds (int, double),Nnumber of seconds (int, double) before the end
MP4Box splitting runs a filter session using the reframer filter as follows:
splitrangeoption of the reframer is always set- source is demultiplexed with
alltkoption set - start and end ranges are passed to
xsandxeoptions of the reframer - for
-splitz, optionsxadjustandxround=afterare enforced - for
-splitg, optionsxadjustandxround=beforeare enforced - for
-splitf, optionxround=seekis enforced andpropbe_refsetif not specified at prompt - for
-splitx, optionxround=closestandpropbe_refare 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. Slay.
-split(string) โ split in files of given max duration (float number) in seconds. A trailing unit can be specified:M,m: duration is in minutesH,h: size is in hours
-split-rap,-splitrโ 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 megabytesG,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 rangesA:BandB:Cshare exactly the same boundaryB:- 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 ๐
๐ธ File Dumping ๐ธ
MP4Box has many dump functionalities, from simple track listing to more complete reporting of special tracks. She contains multitudes, bestie. ๐
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,1being 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-compโ do not decompress boxes when dumping-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-dtsbut does not print offset-dtscโ same as-dtsbut analyses each sample for duplicated dts/cts (slow !) ๐-dtsxcโ same as-dtscbut 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-dsapbut only print sample number-dsapc(int) โ same as-dsapbut only print CTS-dsapd(int) โ same as-dsapbut only print DTS-dsapp(int) โ same as-dsapbut 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. IftkIDis given, dumps from UDTA of the given track ID, otherwisemoovis 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 asorig_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 as4cc_1,4cc_2N-topsize(string) โ print to stdout the number of bytes of top-level boxes matching types given as parameter, formatted as4cc_1,4cc_2Norallfor 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 port2345)-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-dxmloptions-fuzz-chkโ open file without probing and exit (for fuzz tests)
๐ Importing Options ๐
๐ฆ File importing ๐ฆ
Syntax is:
add / cat URL[#FRAGMENT][:opt1...:optN=val]
This process will create the destination file if not existing, and add the track(s) to it. If you wish to always create a new destination file, add -new.
The supported input media types depend on your installation, check filters documentation for more info. iykyk. ๐
To select a desired media track from a source, a fragment identifier # can be specified, before any other options. The following syntax is used:
#video: adds the first video track found in source#audio: adds the first audio track found in source#auxv: adds the first auxiliary video track found in source#pict: adds the first picture track found in source#trackID=IDor#ID: adds the specified track. For IsoMedia files,IDis the track ID. For other media files,IDis the value indicated byMP4Box -info inputFile#pid=ID: number of desired PID for MPEG-2 TS sources#prog_id=ID: number of desired program for MPEG-2 TS sources#program=NAME: name of desired program for MPEG-2 TS sources
By default all imports are performed sequentially, and final interleaving is done at the end; this however requires a temporary file holding original ISOBMF file (if any) and added files before creating the final output. Since this can become quite large, it is possible to add media to a new file without temporary storage, using -flat option, but this disables media interleaving. ๐ฌ
If you wish to create an interleaved new file with no temporary storage, use the -newfs option. The interleaving might not be as precise as when using -new since it is dependent on multiplexer input scheduling (each execution might lead to a slightly different result). Additionally in this mode:
- Some multiplexing options (marked with X below) will be activated for all inputs (e.g. it is not possible to import one AVC track with
xps_inbandand another without). - Some multiplexing options (marked as D below) cannot be used as they require temporary storage for file edition.
- Usage of
catis possible, but concatenated sources will not be interleaved in the output. If you wish to perform more complex cat/add operations without temp file, use a playlist.
Source URL can be any URL supported by GPAC, not limited to local files. ๐
Note bestie ๐ When you're importing SRT or SUB files, MP4Box is gonna pick default layout options so the subtitles show up at the bottom of the video. And likeโฆ you SHOULD NOT import those files before any video track is already in the destination file, otherwise the results are probably gonna be straight-up useless (default SRT/SUB importing uses the default serif font,fontSize 18and display size400x60). Want the full tea? Go check the TTXT doc. โจ
When you import several tracks/sources in one pass, all the options get applied if they're relevant to each source. These options are set for all the imported streams. If you need them per stream instead, set per-file options with the syntax -add stream[:opt1:...:optN]. ๐
The import file name can be set to empty or self, which means the import options should be applied to the destination file track(s). For example:
-add self:moovts=-1:noedit src.mp4
This applies moovts and noedit to all tracks in src.mp4. Another one:
-add self#2:moovts=-1:noedit src.mp4
This applies moovts and noedit to the track with ID=2 in src.mp4. Only per-file options marked with a S work in this mode, just so you know. ๐
When you're importing an ISOBMFF/QT file, only options marked as C or S can be used.
When importing as an external track, only options marked as E can be used.
โจ Allowed per-file options โจ
dur (int)โ XCE โ import only the specified duration from the media. The value can be:- a positive float: that's the duration in seconds
- a fraction: that's the duration as a
NUM/DENfraction - a negative integer: that's the duration in number of coded frames
start (number)โ C โ target start time in the source media. Heads up, it may not be supported depending on the source ๐ญlang (string)โ SE โ set the imported media language codedelay (int)โ SE โ set the imported media initial delay (>0) or initial skip (<0), in ms or as fractional seconds (N/D)par (string)โ S โ set the visual pixel aspect ratio (peep-par)clap (string)โ S โ set the visual clean aperture (peep-clap)mx (string)โ SE โ set the track matrix (peep-mx)name (string)โ S โ set the track handler nameext (string)โ override the file extension when importinghdlr (string)โ S โ set the track handler type to the given code point (4CC)stype (string)โ S โ force the sample description type to the given code point (4CC). Ngl this may likely break the file ๐tkhd (int)โ SE โ set the track header flags, either as a hex integer or as a comma-separated list ofenable,movie,preview,size_arkeywords (usetkhd+=FLAGSto add andtkhd-=FLAGSto remove)disableโ SE โ disable the imported track(s); usedisable=noto force-enable a disabled trackgroup (int)โ SE โ add the track as part of theGalternate group. IfGis0, the first available GroupID gets pickedfps (string)โ S โ same as-fpsrapโ DS โ import only RAP samplesrefsโ DS โ import only reference picturestrailingโ keep trailing 0-bytes in AVC/HEVC samplesagg (int)โ X โ same as-aggdrefโ XC โ same as-drefkeep_refsโ C โ keep track reference when importing a single tracknodropโ same as-no-droppackedโ X โ same as-packedsbrโ same as-sbrsbrxโ same as-sbrxovsbrโ same as-ovsbrpsโ same as-pspsxโ same as-psxasemode (string)โ XS โ set the mode used to create the AudioSampleEntry. The value can be:v0-bs: use MPEG AudioSampleEntry v0 and the channel count from the bitstream (even if it's greater than 2) โ this is the defaultv0-2: use MPEG AudioSampleEntry v0 and force the channel count to 2v1: use MPEG AudioSampleEntry v1 and the channel count from the bitstreamv1-qt: use QuickTime Sound Sample Description Version 1 and the channel count from the bitstream (even if it's greater than 2). This also triggers usingalisdata references instead ofurl, even for non-audio tracks
audio_roll (int)โ S โ add a roll sample group withroll_distanceNfor audio tracksroll (int)โ S โ add a roll sample group withroll_distanceNproll (int)โ S โ add a preroll sample group withroll_distanceNmpeg4โ X โ same as the-mpeg4optionnoseiโ discard all SEI messages during importsvcโ import SVC/LHVC with explicit signaling (no AVC base compatibility)nosvcโ discard SVC/LHVC data when importingsvcmode (string)โ DS โ set the SVC/LHVC import mode. The value can be:split: each layer is in its own trackmerge: all layers are merged in a single tracksplitbase: all layers are merged in a track, and the base goes in anothersplitnox: each layer is in its own track, and no extractors are writtensplitnoxib: each layer is in its own track, no extractors are written, using inband param set signaling
temporal (string)โ DS โ set the HEVC/LHVC temporal sublayer import mode. The value can be:split: each sublayer is in its own tracksplitbase: all sublayers are merged in a track, and the HEVC base goes in anothersplitnox: each layer is in its own track, and no extractors are written
subsamplesโ add SubSample information for AVC+SVCdepsโ import sample dependency information for AVC and HEVCccstโ S โ add a default HEIFccstbox to the visual sample entryforcesyncโ SE โ force non IDR samples with I slices (OpenGOP or GDR) to be marked as sync points
Warning: THE RESULTING FILE IS NOT COMPLIANT WITH THE SPEC โ but it will fix seeking in most players, soโฆ trade-offs, bestie ๐ญ
xps_inbandโ XC โ set xPS inband for AVC/H264 and HEVC (for the reverse operation, re-import from raw media)xps_inbandxโ XC โ same asxps_inbandand it also keeps the first xPS in the sample descriptionau_delimโ keep AU delimiter NAL units in the imported filemax_lid (int)โ set the HEVC max layer ID to be imported toN(by default it imports all layers)max_tid (int)โ set the HEVC max temporal ID to be imported toN(by default it imports all temporal sublayers)tilesโ S โ add HEVC tiles signaling and NALU maps without splitting the tiles into different tile trackssplit_tilesโ DS โ split HEVC tiles into different tile tracks, one tile (or all tiles of one slice) per tracknegcttsโ S โ use negative CTS-DTS offsets (ISO4 brand). Usenegctts=noto force using a positive offset on an existing trackchapโ SE โ specify that the track is a chapter trackchapter (string)โ SE โ add a single chapter (old nero format) with the given name lasting the entire filechapfile (string)โ SE โ add a chapter file (old nero format)layout (string)โ SE โ specify the track layout asWxH[xXxY][xLAYER]. IfW(respH) is0, the max width (resp height) of the tracks in the file is usedrescale (int)โ S โ force media timescale toTS(int or fraction) and change the media durationsampdur (int)โ S โ force all samples duration (D) or sample durations and media timescale (D/TS), used to patch CFR files with broken timingstimescale (int)โ S โ set the imported media timescale toTSmoovts (int)โ SE โ set the movie timescale toTS. A negative value picks the media timescale of the first track importednoeditโ XS โ do not set an edit list when importing B-frames video tracksrvc (string)โ S โ set the RVC configuration for the mediafmt (string)โ override format detection with the given format โ this disables data probing and forces theextoption on the sourceprofile (int)โ S โ override AVC profile. It's an integer value, or one ofhigh444,high,extended,main,baselinelevel (int)โ S โ override AVC level; if the value is< 6, it's interpreted as a decimal expressioncompat (int)โ S โ force the profile compatibility flags for the H.264 contentnovpsextโ remove VPS extensions from the HEVC VPSkeepav1tโ keep the AV1 temporal delimiter OBU in samples, might help if the source file had lossesdlba (string)โ S โ force DolbyAtmos mode for EAC3. The value can be:no: disable Atmos signalingauto: use Atmos signaling from the first sampleN: force Atmos signaling using compatibility type indexN
font (string)โ specify the font name for text import (defaultSerif)size (int)โ specify the font size for text import (default18)text_layout (string)โ specify the track text layout asWxHxXxY- if
W(respH)= 0: the max width (resp height) of the tracks in the file is used - if
Y=-1: the layout gets moved to the bottom of the track area XandYcan be omitted::layout=WxH
- if
swf-globalโ all SWF defines are placed in the first scene replace rather than when neededswf-no-ctrlโ use a single stream for movie control and dictionary (this disables ActionScript)swf-no-textโ remove all SWF textswf-no-fontโ remove all embedded SWF Fonts (local playback host fonts are used instead)swf-no-lineโ remove all lines from SWF shapesswf-no-gradโ remove all gradients from SWF shapesswf-quadโ use quadratic bezier curves instead of cubic onesswf-xlpโ support for lines transparency and scalabilityswf-ic2dโ use indexed curve 2D hardcoded protoswf-same-appโ appearance nodes are reusedswf-flatten (number)โ complementary angle below which 2 lines are merged;0means no flatteningkind (string)โ SE โ set the kind for the track asschemeURI=valuetxtflags (int)โ set the display flags (hexa number) of the text track. Usetxtflags+=FLAGSto add flags andtxtflags-=FLAGSto remove flagsrate (int)โ force average rate and max rate toVAL(in bps) in thebtrtbox. If it's0, thebtrtbox gets removedstz2โ S โ use a compact size table (for low-bitrates)bitdepth (int)โ set bit depth toVALfor imported video content (default is24)colr(string) โ S: set the color profile for your imported video content, bestie. The value has to be formatted like one of these:nclc,p,t,m: wherepis colour primary (int or string),tis transfer characteristics (int or string) andmis matrix coef (int or string), cf-h cicpnclx,p,t,m,r: same as nclx withrfull range flag (yes,onorno,off)prof,path: wherepathis the file containing the ICC color profilerICC,path: wherepathis the file containing the restricted ICC color profile'none': removes color info
hdr(string) โ S: set HDR info on a track (see.I -hdr), and'none'removes HDR info โจdvp,-dv-profile(string) โ S: set the Dolby Vision profile on your imported track. The deets:- Profile is an integer, or
noneto remove DV signaling - Profile can be suffixed with a compatibility ID, e.g.
5.hdr10 - Allowed compatibility ID are
none,hdr10,bt709,hlg709,hlg2100,bt2020,brd, or an integer value as per DV spec - Profile can be prefixed with
fto force DV codec type signaling, e.g.f8.2
- Profile is an integer, or
fullrange(string) โ S: force the video fullrange type in VUI for the AVC|H264 content (valueyes,onorno,off)videofmt(string) โ S: force the video format in VUI for AVC|H264 and HEVC content, value can becomponent,pal,ntsc,secam,mac,undefcolorprim(string) โ S: force the colour primaries in VUI for AVC|H264 and HEVC (int or string, cf-h cicp)colortfc(string) โ S: force transfer characteristics in VUI for AVC|H264 and HEVC (int or string, cf-h cicp)colormx(string) โ S: force the matrix coefficients in VUI for the AVC|H264 and HEVC content (int or string, cf-h cicp)tc(string) โ SE: inject a single QT timecode. Value is formatted as:[d]FPS[/FPS_den],h,m,s,f[,framespertick]: optional drop flag, framerate (integer or fractional), hours, minutes, seconds and frame numberdis an optional flag used to indicate that the counter is in drop-frame format- the
framespertickis optional and defaults toround(framerate); it indicates the number of frames per counter tick
edits(string) โ SE: override edit list, same syntax as.I -editslastsampdur(string) โ S: set the duration of the last sample. Value is formatted as:- no value: use the previous sample duration
- integer: indicate the duration in milliseconds
N/D: indicate the duration as fractional second
ID(int) โ SE: set target ID- a value of
0(default) will try to keep source track ID - a value of
-1will ignore source track ID - other value will try to set track ID to this value if no other track with same ID is present
- a value of
tkgp(string) โ SE: assign a track group to a track. Value is formatted asTYPE,NwithTYPEthe track group type (4CC) andNthe track group ID. A negative ID removes from track group ID-Ntkidx(string) โ SE: set track position in track list,1being first track in fileextkโ CE: add track as external tracktimes(string) โ SE: modify timestamps using the timestamp file specified in value. Timestamp file is formatted as:- a line starting with
#is a comment, in whichtimescale=Vcan be used to set timescale (1000by default) - empty lines are ignored
- one line per sample in decode order, formated as
ctsordts cts
- a line starting with
stats,-fstatโ C: print filter session stats after importgraph,-fgraphโ C: print filter session graph after importsopt:[OPTS]โ setOPTSas additional arguments to the source filter.OPTScan be any usual filter argument, see filter docgpac -h docdopt:[OPTS]โ X: setOPTSas additional arguments to the destination filter.OPTScan be any usual filter argument, see filter docgpac -h doc@f1[:args][@fN:args]โ set a filter chain to insert before the multiplexer. Each filter in the chain is formatted as a regular filter, see filter docgpac -h doc. A@@separator starts a new chain (see DASH help). The last filter in each chain shall not have any ID specified
Note, bestie:sopt,doptand@fmust be placed after all other options. No sneaking them in the middle ๐
๐ Global import options ๐
-add(string) โ add the given file's tracks to the file. Multiple inputs can be specified using+, e.g.-add url1+url2-cat(string) โ concatenate the given file's samples to the file, creating tracks if needed. Multiple inputs can be specified using+, e.g.-cat url1+url2.
Note: This aligns the initial timestamp of the file to be concatenated
-catx(string) โ same as.I catbut new tracks can be imported before concatenation by specifying+ADD_COMMANDwhereADD_COMMANDis a regular.I addsyntax-catpl(string) โ concatenate files listed in the given playlist file (one file per line, lines starting with#are comments).
Note: Each listed file is concatenated as if called with -cat
-unalign-catโ do not attempt to align timestamps of samples in-between tracks-force-catโ skip the media configuration check when concatenating a file.
Warning: THIS MAY BREAK THE CONCATENATED TRACK(S) ๐ญ do not say I didn't warn you
-keep-sysโ keep all MPEG-4 Systems info when using.I addand.I cat(only used when adding IsoMedia files)-drefโ keep media data in the original file using data referencing. The resulting file only contains the meta-data of the presentation (frame sizes, timing, etc...) and references media data in the original file. This is extremely useful when developing content, since importing and storage of the MP4 file is much faster and the resulting file much smaller.
Note: Data referencing may fail on some files because it requires the framed data (e.g. an IsoMedia sample) to be continuous in the original file, which is not always the case depending on the original interleaving or bitstream format (AVC or HEVC cannot use this option)
-no-drop,-nodropโ force constant FPS when importing AVI video-packedโ force packed bitstream when importing raw MPEG-4 part 2 Advanced Simple Profile-sbrโ backward compatible signaling of AAC-SBR-sbrxโ non-backward compatible signaling of AAC-SBR-psโ backward compatible signaling of AAC-PS-psxโ non-backward compatible signaling of AAC-PS-ovsbrโ oversample SBR import (SBR AAC, PS AAC and oversampled SBR cannot be detected at import time)-fps(string) โ force frame rate for video and SUB subtitles import to the given value, expressed as a number, asTS-incorTS/inc.
Note: For raw H263 import, default FPS is15, otherwise25. This is accepted for ISOBMFF import but:rescaleoption should be preferred
-mpeg4โ force MPEG-4 sample descriptions when possible. For AAC, forces MPEG-4 AAC signaling even if MPEG-2-agg(int) โ aggregateNaudio frames in 1 sample (3GP media only, maximum value is15)
๐ Hinting Options ๐
So like, IsoMedia hinting consists in creating special tracks in the file that contain transport protocol specific information and optionally multiplexing information. These tracks are then used by the server to create the actual packets being sent over the network โ in other words they provide the server with hints on how to build packets, hence their names hint tracks ๐
MP4Box supports creation of hint tracks for RTSP servers supporting these such as QuickTime Streaming Server, DarwinStreaming Server or 3GPP-compliant RTSP servers. Iconic behaviour, honestly.
Note: GPAC streaming tools rtp output and rtsp server do not use hint tracks, they use on-the-fly packetization from any media sources, not just MP4
โจ Options: โจ
-hintโ hint the file for RTP/RTSP-mtu(int, default:1450) โ specify RTP MTU (max size) in bytes (this includes 12 bytes RTP header)-copyโ copy media data to hint track rather than reference (speeds up server but takes much more space)-multi[maxptime] โ enable frame concatenation in RTP packets if possible (with max duration100 msormaxptimems if given)-rate(int, default:90000) โ specify rtp rate in Hz when no default for payload-mpeg4โ force MPEG-4 generic payload whenever possible-latmโ force MPG4-LATM transport for AAC streams-staticโ enable static RTP payload IDs whenever possible (by default, dynamic payloads are always used)-add-sdp(string) โ add the given SDP string to movie (string) or track (tkID:string),tkIDbeing the track ID or the hint track ID-no-offsetโ signal no random offset for sequence number and timestamp (support will depend on server)-unhintโ remove all hinting information from file-group-singleโ put all tracks in a single hint group-ocrโ force all MPEG-4 streams to be synchronized (MPEG-4 Systems only)-rapโ signal random access points in RTP packets (MPEG-4 Systems)-tsโ signal AU Time Stamps in RTP packets (MPEG-4 Systems)-sizeโ signal AU size in RTP packets (MPEG-4 Systems)-idxโ signal AU sequence numbers in RTP packets (MPEG-4 Systems)-iodโ prevent systems tracks embedding in IOD (MPEG-4 Systems), not compatible with.I -isma
๐ฌ MPEG-4 Scene Encoding Options
โจ General considerations โจ
okay so here's the tea, bestie: MP4Box does encoding and decoding of BT, XMT, VRML and (partially) X3D formats into MPEG-4 BIFS, plus encoding and decoding of XSR and SVG into MPEG-4 LASeR. it's giving versatile ๐
Any media track you specify through a MuxInfo element gets imported into the resulting MP4 file. automatic. no cap.
want the full lore? go read https://wiki.gpac.io/Howtos/scenecoding/MPEG-4-BIFS-Textual-Format and the related pages ๐ฆ
๐ Scene Random Access ๐
MP4Box can encode BIFS or LASeR streams and insert random access points at a given frequency. this is SO useful when you're packaging content for broadcast, because users will not turn in the scene at the same time (rude of them, honestly). in MPEG-4 terminology this is called the scene carousel. iconic behavior.
๐งฉ BIFS Chunk Processing ๐งฉ
The BIFS chunk encoding mode allows encoding single BIFS access units from an initial context and a set of commands. very demure, very mindful.
The generated AUs are raw BIFS (not SL-packetized), in files called FILE-ESID-AUIDX.bifs, with FILE the basename of the input file.
Commands with a timing of 0 in the input will modify the carousel version only (i.e. output context). Commands with a timing different from 0 in the input will generate new AUs. periodt.
Options:
-mp4โ specify input file is for BIFS/LASeR encoding-defโ encode DEF names in BIFS-sync (int)โ force BIFS sync sample generation every given time in ms (cannot be used with shadow or carousel)-shadow (int)โ force BIFS sync shadow sample generation every given time in ms (cannot be used with sync or carousel)-carousel (int)โ use BIFS carousel (cannot be used with sync or shadow)-sclogโ generate scene codec log file if available-ms (string)โ import tracks from the given file-ctx-in (string)โ specify initial context (MP4/BT/XMT) file for chunk processing. Input file must be a commands-only file-ctx-out (string)โ specify storage of updated context (MP4/BT/XMT) file for chunk processing, optional-resolution (int)โ resolution factor (-8to7, default0) for LASeR encoding, and all coordinates are multiplied by2^resbefore truncation (LASeR encoding)-coord-bits (int)โ number of bits used for encoding truncated coordinates (0to31, default12) (LASeR encoding)-scale-bits (int)โ extra bits used for encoding truncated scales (0to4, default0) (LASeR encoding)-auto-quant (int)โ resolution is given as if using resolution but coord-bits and scale-bits are inferred (LASeR encoding)-global-quant (int)โ resolution is given as if using resolution but the res is inferred (BIFS encoding)
๐ 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 https://wiki.gpac.io/xmlformats/Common-Encryption
Image files (HEIF) can also be crypted / decrypted, using CENC only.
Options:
-crypt (string)โ encrypt the input file using the given CryptFile-decrypt (string)โ decrypt the input file, potentially using the given CryptFile. If CryptFile is not given, will fail if the key management system is not supported-set-kms tkID=kms_uriโ change ISMA/OMA KMS location for a given track or for all tracks ifall=is used
๐ผ๏ธ Meta and HEIF Options ๐ผ๏ธ
IsoMedia files can be used as generic meta-data containers โ for example, storing XML information and sample images for a movie. The resulting file may not always contain a movie, as is the case with some HEIF files or MPEG-21 files. ngl that's a whole vibe shift and it's valid.
These information can be stored at the file root level (as is the case for HEIF/IFF and MPEG-21 file formats), or at the movie or track level for a regular movie.
-set-meta ABCD[:tk=tkID]โ set meta box type, withABCDthe four char meta type (NULLor0to remove meta)tknot set: use root (file) metatkID == 0: use moov metatkID != 0: use meta of given track
-add-item (string)โ add resource to meta, with parameter syntaxfile_path[:opt1:optN]file_paththisorself: item is the file itselftk=tkID: meta location (file, moov, track)name=str: item name, none if not settype=itype: item 4cc type (not needed if mime is provided)mime=mtype: item mime type, none if not setencoding=enctype: item content-encoding type, none if not setid=ID: item ID (strictly positive integer)ref=4cc,id: reference of type 4cc (such as'dimg','auxl','cdsc') to an other item (can be set multiple times)group=4cc,id: indicate the type 4cc (such as'altr') and id of an entity group this item belongs toreplace: replace existing item by new item
-add-image (string)โ add the given file as HEIF image item, with parameter syntaxfile_path[:opt1:optN]. If filepath is omitted, source is the input MP4 filename,id,ref,group: see add-itemprimary: indicate that this item should be the primary itemtime=t[-e][/i]: use the next sync sample after timet(float, in sec, default0). A negative time imports ALL intra frames as items- If
eis set (float, in sec), import all sync samples betweentande - If
iis set (float, in sec), sets time increment between samples to import
- If
split_tiles: for an HEVC tiled image, each tile is stored as a separate itemimage-size=wxh: force setting the image size and ignoring the bitstream info, used for grid, overlay and identity derived images alsorotation=a: set the rotation angle for this image to90*adegrees anti-clockwisemirror-axis=axis: set the mirror axis:vertical,horizontalclap=Wn,Wd,Hn,Hd,HOn,HOd,VOn,VOd: see track clapimage-pasp=axb: force the aspect ratio of the imageimage-pixi=(a|a,b,c): force the bit depth (1or3channels)hidden: indicate that this image item should be hiddenicc_path: path to icc data to add as color infoalpha: indicate that the image is an alpha image (should useref=auxlalso)depth: indicate that the image is a depth image (should useref=auxlalso)it=ID: indicate the item ID of the source item to importitp=ID: same asit=but copy over all properties of the source itemtk=tkID: indicate the track ID of the source sample. If0, uses the first video track in the filesamp=N: indicate the sample number of the source sampleref: do not copy the data but refer to the final sample/item location, ignored if filepath is setagrid[=AR]: creates an automatic grid from the image items present in the file, in their declaration order. The grid will try to haveARaspect ratio if specified (float), or the aspect ratio of the source otherwise. The grid will be the primary item and all other images will be hiddenav1_op_index: select the AV1 operating point to use viaa1opboxreplace: replace existing image by new image, keeping props listed inkeep_propskeep_props=4CCs: coma-separated list of properties types to keep when replacing the image, e.g.keep_props=auxCauxt=URN: mark image as auxiliary using given URNauxd=FILE: use data fromFILEas auxiliary extensions (cfauxCbox)- any other options will be passed as options to the media importer, see
-add
-add-derived-image (string)โ create an image grid, overlay or identity item, with parameter syntax:type=(grid|iovl|iden)[:opt1:optN]image-grid-size=rxc: set the number of rows and columns of the gridimage-overlay-offsets=h,v[,h,v]*: set the horizontal and vertical offsets of the images in the overlayimage-overlay-color=r,g,b,a: set the canvas color of the overlay[0-65535]- any other options from add-image can be used
-rem-item,-rem-image item_ID[:tk=tkID]โ remove resource from meta-set-primary item_ID[:tk=tkID]โ set item as primary for meta-set-xml xml_file_path[:tk=tkID][:binary]โ set meta XML data-rem-xml [tk=tkID]โ remove meta XML data-dump-xml file_path[:tk=tkID]โ dump meta XML to file-dump-item item_ID[:tk=tkID][:path=fileName]โ dump item to file-package (string)โ package input XML file into an ISO container, all media referenced except hyperlinks are added to file-mgt (string)โ package input XML file into an MPEG-U widget with ISO container, all files contained in the current folder are added to the widget package
๐ง SWF Importer Options ๐ง
MP4Box can import simple Macromedia Flash files (".SWF") ๐ซถ throwback era fr fr.
You can specify a SWF input file with '-bt', '-xmt' and '-mp4' options
Options:
-globalโ all SWF defines are placed in first scene replace rather than when needed-no-ctrlโ use a single stream for movie control and dictionary (this will disable ActionScript)-no-textโ remove all SWF text-no-fontโ remove all embedded SWF Fonts (local playback host fonts used)-no-lineโ remove all lines from SWF shapes-no-gradโ remove all gradients from swf shapes-quadโ use quadratic bezier curves instead of cubic ones-xlpโ support for lines transparency and scalability-ic2dโ use indexed curve 2D hardcoded proto-same-appโ appearance nodes are reused-flatten (number)โ complementary angle below which 2 lines are merged, value0means no flattening
๐ท๏ธ Tagging support ๐ท๏ธ
Tags get written as a colon-separated list, bestie, like this:
tag_name=tag_value[:tag2=val2]
- Setting a tag with no value, or a value of
NULL, removes the tag. - The special tag value
clear(orreset) removes all the tags. poof ๐จ - The special tag value
custmeans it's a custom domain tag โ and in that case the tag value must start withDOMAIN,MEAN,.
Example
-itags cust='com.apple.iTunes,iTunEXTC,My Tag Value'
The DOMAIN and/or NAME strings can be empty, no stress. Unsupported tags? You can add them using their four character code as the tag name, and the value will be assumed to be a string. And if your tag name is only 3 characters long, the prefix 0xA9 gets used to build the four character code. cute ๐
You can also load tags from a text file with -itags filename. That file has to be in UTF8 and follow this vibe:
- lines starting with
tag_name=valuekick off a new tag - every other line is the continuation of the last declared tag
If the tag name starts with WM/, the tag goes into the Xtra box (that's a WMA tag, string only).
๐ QT metadata key ๐
The tag gets added as a QT metadata key if:
tag_namestarts withQT/- or
tag_nameisn't recognized and is longer than 4 characters
Your tag_name can optionally be prefixed with HDLR@, which sets the tag namespace 4CC โ and the default namespace is mdta.
And the tag_value can be prefixed with:
S:force string encoding (this one has to go first) instead of parsing the tag valueb:use 8-bit encoding for signed or unsigned ints:use 16-bit encoding for signed or unsigned intl:use 32-bit encoding for signed or unsigned intL:use 64-bit encoding for signed or unsigned intf:force float encoding for numbers
Numbers get converted by default and stored in variable-size mode. And if you wanna force a positive integer into signed storage, just slap a + in front of the number. periodt ๐
Example
-tags io.gpac.some_tag=s+32
This forces storing the value 32 in signed 16 bit format. slay.
The tag_value can also be formatted as:
XxY@WxH: a rectangle typeXxY: a point typeW@H: a size typeA,B,C,D,E,F,G,H,I: a 3x3 matrixFNAME: data is loaded fromFNAME, type set tojpegorpngif needed
โจ Supported tag names (name, value, type, aliases) โจ
title(ยฉnam) โ string (aliasname)artist(ยฉART) โ stringalbum_artist(aART) โ string (aliasalbumArtist)album(ยฉalb) โ stringgroup(ยฉgrp) โ string (aliasgrouping)composer(ยฉcom) โ stringwriter(ยฉwrt) โ stringconductor(ยฉcon) โ stringcomment(ยฉcmt) โ string (aliascomments)genre(gnre) โ string (ID3 genre tag)created(ยฉday) โ string (aliasreleaseDate)track(ยฉtrk) โ stringtracknum(trkn) โ fraction (syntax:A/BorA,Bwill be 0)disk(disk) โ fraction (syntax:A/BorA,Bwill be 0)tempo(tmpo) โ integercompilation(cpil) โ bool (yesorno)show(tvsh) โ string (aliastvShow)episode_id(tven) โ string (aliastvEpisodeID)season(tvsn) โ integer (aliastvSeason)episode(tves) โ integer (aliastvEPisode)network(tvnn) โ string (aliastvNetwork)sdesc(desc) โ string (aliasdescription)ldesc(ldes) โ string (aliaslongDescription)lyrics(ยฉlyr) โ stringsort_name(sonm) โ string (aliassortName)sort_artist(soar) โ string (aliassortArtist)sort_album_artist(soaa) โ string (aliassortAlbumArtist)sort_album(soal) โ string (aliassortAlbum)sort_composer(soco) โ string (aliassortComposer)sort_show(sosn) โ string (aliassortShow)cover(covr) โ file path (aliasartwork)copyright(cprt) โ stringtool(ยฉtoo) โ string (aliasencodingTool)encoder(ยฉenc) โ string (aliasencodedBy)pdate(purd) โ string (aliaspurchaseDate)podcast(pcst) โ bool (yesorno)url(purl) โ string (aliaspodcastURL)keywords(kyyw) โ stringcategory(catg) โ stringhdvideo(hdvd) โ integermedia(stik) โ integer (aliasmediaType)rating(rtng) โ integer (aliascontentRating)gapless(pgap) โ bool (yesorno)art_director(ยฉard) โ stringarranger(ยฉarg) โ stringlyricist(ยฉaut) โ stringacknowledgement(ยฉcak) โ stringsong_description(ยฉdes) โ stringdirector(ยฉdir) โ stringequalizer(ยฉequ) โ stringliner(ยฉlnt) โ stringrecord_company(ยฉmak) โ stringoriginal_artist(ยฉope) โ stringphono_rights(ยฉphg) โ stringproducer(ยฉprd) โ stringperformer(ยฉprf) โ stringpublisher(ยฉpub) โ stringsound_engineer(ยฉsne) โ stringsoloist(ยฉsol) โ stringcredits(ยฉsrc) โ stringthanks(ยฉthx) โ stringonline_info(ยฉurl) โ stringexec_producer(ยฉxpd) โ stringgenre(ยฉgen) โ string (ID3 genre tag)location(ยฉxyz) โ string
๐ฌ Live Scene Encoder Options ๐ฌ
These options get specified as opt_name=opt_val. Here's the menu, bestie:
-liveโ enable live BIFS/LASeR encoder-dst(string) โ destination IP-port(int, default:7000) โ destination port-mtu(int, default:1450) โ path MTU for RTP packets-ifce(string) โ IP address of the physical interface to use-ttl(int, default:1) โ time to live for multicast packets-sdp(string, default:session.sdp) โ output SDP file-dimsโ turn on DIMS mode for SVG input-no-rapโ disable RAP sending and carousel generation-src(string) โ source of scene updates-rap(int) โ duration in ms of base carousel; you can specify the RAP period of a single ESID (not in DIMS) usingESID=X:time
Runtime options, aka the lil keyboard shortcuts ๐ซถ:
q: quitsu: inputs some commands to be sentU: same asubut signals the updates as criticale: inputs some commands to be sent without being aggregatedE: same asebut signals the updates as criticalf: forces RAP sendingF: forces RAP regeneration and sendingp: dumps current scene
๐ธ EXAMPLES ๐ธ
Basic and advanced examples are available at https://wiki.gpac.io/MP4Box/MP4Box โ go look, it's giving tutorial energy ๐
๐ MORE ๐
Authors: GPAC developers, see git repo history (-log)
For bug reports, feature requests, more information and source code, visit https://github.com/gpac/gpac
build: 26.02
Copyright: (c) 2000-2024 Telecom Paris distributed under LGPL v2.1+ - https://gpac.io
๐ SEE ALSO ๐
okay bestie that's literally the whole page, you ate it up ๐
โจ This was the MP4Box(1) manpage โ source/version MP4Box, dated 2019. no cap, go tag some files ๐๐ฆ
๐ฆ where this page comes from
- fedora 44: gpac 26.02.0-1.fc44 ยท LGPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms