Skip to main content

FFmpeg

Help Wanted

This section is in need of contributions. If you believe you can help, please see our Contribution Guide to get started as a contributor!

FFmpeg is a multimedia framework that has utilities for transcoding, transmuxing, and filtering audio and video. It provides the ffmpeg, ffprobe, and ffplay command-line utilities. It also features the libav* libraries, which allow you to use the functionality of FFmpeg without the programs.

Installation

There are a number of ways to install FFmpeg depending on the operating system you're using.

Linux & macOS​

Package Manager

The easiest way to obtain FFmpeg is through your package manager. On most package managers, the package is simply named ffmpeg, however ffprobe and ffplay may have their own packages. Note that the packages may be outdated.

Compiling from source

A more complete guide is available at the FFmpeg Compilation Guide. Simplifying things a bit, what you need to do is:

  • grab the sources or clone from FFmpeg's git: git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
  • Enter the directory & run ./configure --help to see a list of features and libraries you can choose to build with.
  • Install all libraries you want to build FFmpeg with.
  • Run ./configure with --enable- flags as desired.
  • Run make, or make -j $(nproc) on Linux to properly make use of multiple cores. on macOS, this would be make -j $(sysctl -n hw.ncpu).
  • Run make install. May require root.

Windows​

There are no official binaries for FFmpeg on Windows, but you can download third-party binaries:

Using FFmpeg

ffmpeg is the primary command-line tool of FFmpeg. It takes 0 or more files as inputs & outputs.

ffmpeg's command-line arguments are positional, meaning it matters where you put each option. Each input and output has its own arguments. For example, ffmpeg -r 24 -i file1 file2 applies the -r 24 option to the input file1, interpreting the video as having that frame rate, while ffmpeg -i file1 -r 24 file2 applies the -r 24 option to file2. To get a list of options, refer to the more verbose FFmpeg documentation.

Transcode a video​

ffmpeg -i [input] -c:v [video_codec] -b:v [video_bitrate] -c:a [audio_codec] -b:a [audio_bitrate] output
OptionMeaning
-c:v video_encodercodec for the automatically selected video stream
-b:v video_bitratebitrate for the automatically selected video stream
-c:a audio_encodercodec for the automatically selected audio stream
-b:a audio_bitratebitrate for the automatically selected audio stream

Transmux a video​

ffmpeg -i [input] -c copy [output]
OptionMeaning
-c copyset the codec to copy

Filter a video​

ffmpeg -i [input] -c:v [video_encoder] -c:a [audio_codec] (...) -vf [filter_name] output
OptionMeaning
-vf filter_nameset the video filter to filter_name

Container selection​

FFmpeg will usually select the appropriate container based on the file extension of the output. If it doesn't detect the correct container, you can specify it with -f.

OptionMeaning
-f format_nameset the format to format_name

References: [^multimediawiki-howtos]: HOWTO Search Results - MultimediaWiki

Special thanks to bluefalcon's encoding guide for this material, licensed under CC BY-SA 4.0. Our adaptation features formatting changes & content changes, specifically regarding the titles of some headings.