FFmpeg Options

Here is a list of some of the main FFmpeg options and filters we use…

-i Specify the input to the transcode

-f The container format (eg. mov) if it isn’t obvious from the filename extension (can be applied both to the input and output file). image2 is a special format that represents a single still image or an image sequence.

-an This is a video only transcode and we want no audio.

-ss Start offset (in seconds) into the input file where to start transcode. This can be specified either before or after the -i argument and has works differently in each case. Before it’s quicker but possibly less accurate, afterwards it’s slower (because we’re telling FFmpeg to

decode all the frames and skip any before the specified start time) but very precise, so sometimes when decoding movies with interframe compression we will combine both to do a quick seek to the nearest key frame followed by a slow but accurate seek after the key frame.

-t The duration we want to transcode

-vcodec (or -codec:v) The video codec to use (eg. ‘x264’, or ‘copy’ for passthrough without re-encoding)

-vf Specify one or more video filters to apply (a chain of filters), such as deinterlacing, scaling the video frame size, or adding burnt in text or timecode or watermark image.

-movie_timescale Which timescale or timebase (the denominator in time calculations) to use in the exported movie. FFmpeg picks some very strange defaults when exporting to QuickTime so we need to specify this for frame accuracy.

-video_track_timescale As above (the movie header and track media can have different timescales)

-g Set the key frame interval

-timecode Specify start timecode when adding a timecode track

-metadata Specify metadata to be embedded in the output file, such as title or copyright annotations

-pix_fmt The video pixel format (can be specified as an input or output option, we typically specify yuv420p when exporting to MOV to generate a file that is compatible with QuickTime).

-r The video frame rate (can be specified as an input or output option)

-s The frame size

-vn This is an audio only transcode and we don’t want any video

-acodec (or -codec:a) The audio codec to use (eg. ‘pcm_s16le’)

-ar The audio sample rate (eg. 44.1kHz)

-ac Force the number of audio channels in the output

-map Which streams (tracks and channels) from the source file we are interested in and want to extract (e.g. the source file might have multiple audio tracks)

There are different ways of specifying the encoding quality and bit rate. Different codecs support different methods:

-b:v Specify a target bit rate for the video

-qscale:v Specify a subjective video quality from 0 (highest quality) to 31 (smallest files)

-crf The x264 and x265 video codecs use a CRF scale (from 0 to 51) to specify quality

-preset The x264 and x265 codecs also support a preset option that tells it to do to multiple tuning passes and can result in marginally smaller and better quality files at the cost of much slower encode times

-b:a Specify a target bit rate for the audio

-vbr The Fraunhofer AAC audio encoder uses VBR presets from 1 to 5 to specify quality

We use the following video filters:

bwdif De-interlace the video (remove “jaggies” if the input video is interlaced)

lut3d Apply a LUT

drawtext Burn in text such as a fixed overlay, markers, title slate etc. and also used for burnt in timecode. It takes a number of parameters like the text to use, start timecode, font file, X and Y position, font size and colour, and so on.

overlay Superimpose a burnt in watermark image transpose Used when the input video needs to be rotated rotate Used when the input video needs to be rotated fps Adjust the frame rate

scale Re-scale the image

setsar Make sure we’re using square pixels

setdar Set the display aspect ratio And the following audio filters:

aevalsrc Generate an audio tone

anullsrc Generate blank audio

channelsplit Split a track with multiple audio channels (eg. stereo or 5.1 surround sound) into separate tracks

pan Similar to channelsplit, used when the source track has a non-standard number of channels which channelsplit doesn’t support

amerge Combine two mono tracks into a stereo track etc. amix Implement mix down

channelmap Change the audio layout

See FFCommandLine.buildArguments() for when the “Direct export” option is selected, or VideoExporter.buildArgs(), AudioExporter.buildArguments() and SegmentTranscoder.buildFinalArgs() in the normal case of segment-based exports.

We try to expose all the most useful and most common FFmpeg options via the user interface in the export settings dialog but it’s possible to specify additional options (and even to modify existing options using regex) in the Advanced Options field.

For further details on the huge number of options FFmpeg supports see https://ffmpeg.org/ffmpeg.html and https://ffmpeg.org/ffmpeg-filters.html and https://trac.ffmpeg.org/wiki/AudioChannelManipulation (plus many other sources of online FFmpeg documentation).