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_ref`set 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`.  
    
<div markdown class="option">
<a id="split" data-level="basic">__-split__</a> (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  
</div>
  
<div markdown class="option">
<a id="split-rap" data-level="basic">__-split-rap__</a>,__-splitr__ (string): split in files at each new RAP  
</div>
<div markdown class="option">
<a id="split-size" data-level="basic">__-split-size__</a>,__-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  
</div>
  
<div markdown class="option">
<a id="split-chunk" data-level="basic">__-split-chunk__</a>,__-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  
</div>
  
<div markdown class="option">
<a id="splitz" data-level="basic">__-splitz__</a> (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  
</div>
  
<div markdown class="option">
<a id="splitg" data-level="basic">__-splitg__</a> (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  
</div>
  
<div markdown class="option">
<a id="splitf" data-level="basic">__-splitf__</a> (string): extract the specified time range and insert edits such that the extracted output is exactly the specified range  
  
</div>