FFmpeg
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 --helpto see a list of features and libraries you can choose to build with. - Install all libraries you want to build FFmpeg with.
- Run
./configurewith--enable-flags as desired. - Run
make, ormake -j $(nproc)on Linux to properly make use of multiple cores. on macOS, this would bemake -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
| Option | Meaning |
|---|---|
-c:v video_encoder | codec for the automatically selected video stream |
-b:v video_bitrate | bitrate for the automatically selected video stream |
-c:a audio_encoder | codec for the automatically selected audio stream |
-b:a audio_bitrate | bitrate for the automatically selected audio stream |
Transmux a videoâ
ffmpeg -i [input] -c copy [output]
| Option | Meaning |
|---|---|
-c copy | set the codec to copy |
Filter a videoâ
ffmpeg -i [input] -c:v [video_encoder] -c:a [audio_codec] (...) -vf [filter_name] output
| Option | Meaning |
|---|---|
-vf filter_name | set 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.
| Option | Meaning |
|---|---|
-f format_name | set 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.