FFmpeg recipes

FFmpeg is an open source command line tool to convert multimedia files between formats and optionally apply a wide range of filters and effects.

Basic video conversion

ffmpeg -i input.mov output.mp4

FFmpeg can be very simple to use. It has useful defaults for quality and video/audio codecs to use, so you tend to get what you expect for well-defined file formats.

Generate Apple-compatible HEVC H265 encoding

ffmpeg -i input.mov -c:v libx265 -crf 28 -c:a aac -b:a 128k -tag:v hvc1 output.mp4

The -c:v libx265 sets the video codec to H265.

The constant rate factor (crf) defaults to 28 for H265 encoding, so the -crf 28 option in this command is redundant, but you can make the number lower (for higher quality) or higher (for lower quality). The range is between 0 and 51, but the extreme values aren’t much use. Changing the crf setting by 6 in either direction will roughly double/halve the video bitrate.

In this example we’re setting the audio codec (-c:a aac) and bitrate (-b:a 128k). AAC is chosen by default for mp4 files, so it may not be necessary to specify the audio settings. If the source audio is already in a reasonable format and you just want to re-encode the video, then -c:a copy can be used to exactly copy the audio without re-encoding.

The -tag:v hvc1 option is the key to making the resulting video compatible with the Apple QuickTime player.