Options

Fragmentation is enabled by setting one of the AVOptions that define how to cut the file into fragments:

'-moov_size bytes'

Reserves space for the moov atom at the beginning of the file instead of placing the moov atom at the end. If the space reserved is insufficient, muxing will fail.

'-movflags frag_keyframe'

Start a new fragment at each video keyframe.

'-frag_duration duration'

Create fragments that are duration microseconds long.

'-frag_size size'

Create fragments that contain up to size bytes of payload data.

'-movflags frag_custom'

Allow the caller to manually choose when to cut fragments, by calling av_write_frame(ctx, NULL) to write a fragment with the packets written so far. (This is only useful with other applications integrating libavformat, not from ffmpeg.)

'-min_frag_duration duration'

Don't create fragments that are shorter than duration microseconds long.

If more than one condition is specified, fragments are cut when one of the specified conditions is fulfilled. The exception to this is -min_frag_duration, which has to be fulfilled for any of the other conditions to apply.

Additionally, the way the output file is written can be adjusted through a few other options:

'-movflags empty_moov'

Write an initial moov atom directly at the start of the file, without describing any samples in it. Generally, an mdat/moov pair is written at the start of the file, as a normal MOV/MP4 file, containing only a short portion of the file. With this option set, there is no initial mdat atom, and the moov atom only describes the tracks but has a zero duration.

This option is implicitly set when writing ismv (Smooth Streaming) files.

'-movflags separate_moof'

Write a separate moof (movie fragment) atom for each track. Normally, packets for all tracks are written in a moof atom (which is slightly more efficient), but with this option set, the muxer writes one moof/mdat pair for each track, making it easier to separate tracks.

This option is implicitly set when writing ismv (Smooth Streaming) files.

'-movflags skip_sidx'

Skip writing of sidx atom. When bitrate overhead due to sidx atom is high, this option could be used for cases where sidx atom is not mandatory. When global_sidx flag is enabled, this option will be ignored.

'-movflags faststart'

Run a second pass moving the index (moov atom) to the beginning of the file. This operation can take a while, and will not work in various situations such as fragmented output, thus it is not enabled by default.

'-movflags rtphint'

Add RTP hinting tracks to the output file.

'-movflags disable_chpl'

Disable Nero chapter markers (chpl atom). Normally, both Nero chapters and a QuickTime chapter track are written to the file. With this option set, only the QuickTime chapter track will be written. Nero chapters can cause failures when the file is reprocessed with certain tagging programs, like mp3Tag 2.61a and iTunes 11.3, most likely other versions are affected as well.

'-movflags omit_tfhd_offset'

Do not write any absolute base_data_offset in tfhd atoms. This avoids tying fragments to absolute byte positions in the file/streams.

'-movflags default_base_moof'

Similarly to the omit_tfhd_offset, this flag avoids writing the absolute base_data_offset field in tfhd atoms, but does so by using the new default-base-is-moof flag instead. This flag is new from 14496-12:2012. This may make the fragments easier to parse in certain circumstances (avoiding basing track fragment location calculations on the implicit end of the previous track fragment).

'-write_tmcd'

Specify on to force writing a timecode track, off to disable it and auto to write a timecode track only for mov and mp4 output (default).

'-movflags negative_cts_offsets'

Enables utilization of version 1 of the CTTS box, in which the CTS offsets can be negative. This enables the initial sample to have DTS/CTS of zero, and reduces the need for edit lists for some cases such as video tracks with B-frames. Additionally, eases conformance with the DASH-IF interoperability guidelines.

This option is implicitly set when writing ismv (Smooth Streaming) files.

'-write_prft'

Write producer time reference box (PRFT) with a specified time source for the NTP field in the PRFT box. Set value as 'wallclock' to specify timesource as wallclock time and 'pts' to specify timesource as input packets' PTS values.

Setting value to 'pts' is applicable only for a live encoding use case, where PTS values are set as as wallclock time at the source. For example, an encoding use case with decklink capture source where 'video_pts' and 'audio_pts' are set to 'abs_wallclock'.