Skip to content

FFmpeg

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

To be filled.

Using FFmpeg

ffmpeg is the primary command-line tool of FFmpeg. It takes 0 or more bitstreams 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.

Video Transcoding

Terminal window
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_codeccodec for the automatically selected audio stream
-b:a audio_bitratebitrate for the automatically selected audio stream

Transmux a video

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

Filter a video

Terminal window
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

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.