- FFmpeg Compilation Guide
- All platforms
- Linux
- macOS
- Windows
- Other Platforms
- Performance Tips
- Compile FFmpeg for Ubuntu, Debian, or Mint
- Contents
- Get the Dependencies
- Compilation & Installation
- libx264
- libx265
- libvpx
- libfdk-aac
- libopus
- libaom
- libsvtav1
- libdav1d
- libvmaf
- FFmpeg
- Usage
- Documentation
- Updating FFmpeg
- Reverting Changes made by this Guide
- Why install to
- Why are the commands in this guide so complicated?
- make[1]: Nothing to be done for ‘all’/’install’
- If You Need Help
- How to Install FFmpeg in Linux
- How to Install FFmpeg Multimedia Framework in Linux
- Install FFmpeg on Ubuntu and Linux Mint
- Install FFmpeg on Debian
- Install FFmpeg on CentOS and RHEL
- Install FFmpeg on Fedora
- Install FFmpeg on Arch Linux
- Install FFmpeg on openSUSE
- FFmpeg Compiling from Source
- Conclusion
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Related Posts
- 11 thoughts on “How to Install FFmpeg in Linux”
- Got something to say? Join the discussion. Cancel reply
FFmpeg Compilation Guide
This page contains a list of resources which describe the necessary steps required for compiling FFmpeg from scratch or with the help of build scripts and/or package managers.
All platforms
Read the Generic compilation guide, regardless of your platform. It provides generic compilation and installation instructions, including the use of configure .
- CompilationGuide/vcpkg – vcpkg also aims to be portable accross all platforms. For windows it uses MinGW/MSYS compilation toolchain.
Linux
Alternative ways to obtain/compile ffmpeg under Linux:
macOS
Windows
- CompilationGuide/MinGW – MinGW Compilation Guide for compiling FFmpeg with Windows/MinGW/MSYS.
- CompilationGuide/CrossCompilingForWindows – Cross compiling for Windows is sometimes easier than using MSYS+MinGW.
- CompilationGuide/WinRT – Compiling FFmpeg for Windows Apps (Windows 10 and Windows 8.1)
- CompilationGuide/MSVC – Compiling FFmpeg using MSYS+MSVC, see also:
- Instructions on the reference web page
- Roxlu’s guide
Using external scripts or tools:
- Media Autobuild Suite – Automatically build FFmpeg under Windows
- Linuxbrew, which can be used with Windows Subsystem for Linux (WSL)
- Chocolatey – a package manager for Windows with an FFmpeg package
Other Platforms
Performance Tips
There are numerous avenues to extract maximum performance out of FFmpeg when it is built from source. The following list describes some of them:
- If using GCC/Clang , consider adding -march=native to —extra-cflags to make slightly better use of your hardware. Alternatively, for a more general solution, examine the —arch and —cpu options. Gains are variable, and usually quite small. However, this is usually even more safe than the above, and is thus listed here.
- Depending on your use case, —enable-hardcoded-tables may be a useful option. It results in an increase of approximately 15% in the size of libavcodec , the main library impacted by this change. It enables savings in table generation time, done once at codec initialization, since by hardcoding the tables, they do not need to be computed at runtime. However, the savings are often negligible (
100k cycles is a typical number) especially when amortized over the entire encoding/decoding operation. By default, this is not enabled. Improvements are being made to the runtime initialization, and so over time, this option will have an impact on fewer and fewer codecs.
- Other options may be found by examining ./configure —help .
Источник
Compile FFmpeg for Ubuntu, Debian, or Mint
Contents
This guide for standard support releases of Ubuntu, Debian, and Linux Mint and will provide a local, non-system installation of FFmpeg with several external libraries.
You may also refer to the Generic Compilation Guide for additional information about compiling software.
Recent static builds are also available for lazy people or those who are unable to compile. The static builds do not support non-free libraries.
Note: FFmpeg is part of the Ubuntu packages and can be installed via apt-get install ffmpeg . You may still wish to compile if you want the latest version, experience a bug, or want to customize your build, and it will not interfere with the ffmpeg package in the repository.
This guide is designed to be non-intrusive and will create several directories in your home directory:
- ffmpeg_sources – Where the source files will be downloaded. This can be deleted if desired when finished with the guide.
- ffmpeg_build – Where the files will be built and libraries installed. This can be deleted if desired when finished with the guide.
- bin – Where the resulting binaries ( ffmpeg , ffplay , ffprobe , x264 , x265 ) will be installed.
You can easily undo any of this as shown in Reverting Changes Made by This Guide.
Get the Dependencies
These are packages required for compiling, but you can remove them when you are done if you prefer:
On Ubuntu 20.04 you may also need this command: ( note)
Note: Server users can omit the ffplay and x11grab dependencies: libsdl2-dev libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev .
In your home directory make a new directory to put all of the source code and binaries into:
Compilation & Installation
This guide assumes that you want to install some of the most common third-party libraries. Each section provides you with the commands needed to install that library.
For each section, copy-paste the entire code-block into your shell.
If you do not require certain features, you may skip the relevant section (if it is not required) and then remove the appropriate ./configure option in FFmpeg. For example, if libvpx is not needed, skip that section and then remove —enable-libvpx from the Install FFmpeg section.
Tip: To significantly speed up the compilation process on systems with multiple cores, you can use the -j option with each make command to set the number of compilation jobs allowed to run simultaneously, such as make -j4 . To set this to the number of available logical CPU cores, use make -j$(nproc) . The -j option also works with the ninja build system used to compile some of the libraries in this guide. Using all cores may cause your machine to become slow or unresponsive.
An assembler used by some libraries.
If your repository provides nasm version ≥ 2.13 then you can install that instead of compiling:
Otherwise you can compile:
libx264
H.264 video encoder. See the H.264 Encoding Guide for more information and usage examples.
Requires ffmpeg to be configured with —enable-gpl —enable-libx264 .
If your repository provides libx264-dev version ≥ 118 then you can install that instead of compiling:
Otherwise you can compile:
libx265
H.265/HEVC video encoder. See the H.265 Encoding Guide for more information and usage examples.
Requires ffmpeg to be configured with —enable-gpl —enable-libx265 .
If your repository provides libx265-dev version ≥ 68 then you can install that instead of compiling:
Otherwise you can compile:
libvpx
VP8/VP9 video encoder/decoder. See the VP9 Video Encoding Guide for more information and usage examples.
Requires ffmpeg to be configured with —enable-libvpx .
If your repository provides libvpx-dev version ≥ 1.4.0 then you can install that instead of compiling:
Otherwise you can compile:
libfdk-aac
AAC audio encoder. See the AAC Audio Encoding Guide for more information and usage examples.
Requires ffmpeg to be configured with —enable-libfdk-aac (and —enable-nonfree if you also included —enable-gpl ).
If your repository provides libfdk-aac-dev then you can install that instead of compiling:
Otherwise you can compile:
libopus
Opus audio decoder and encoder.
Requires ffmpeg to be configured with —enable-libopus .
If your repository provides libopus-dev version ≥ 1.1 then you can install that instead of compiling:
Otherwise you can compile:
libaom
AV1 video encoder/decoder:
Warning: libaom does not yet appear to have a stable API, so compilation of libavcodec/libaomenc.c may occasionally fail. Just wait a day or two for us to catch up with these annoying changes, re-download ffmpeg-snapshot.tar.bz2 , and try again. Or skip libaom altogether.
libsvtav1
AV1 video encoder/decoder. Only the encoder is supported by FFmpeg, so building of the decoder is disabled.
Requires ffmpeg to be configured with —enable-libsvtav1 .
libdav1d
AV1 decoder, much faster than the one provided by libaom.
Requires ffmpeg to be configured with —enable-libdav1d .
If your repository provides libdav1d-dev , you can install that instead of compiling:
Otherwise you’ll need can build from source. Users whose distributions don’t provide a recent enough version of meson (0.49.0 or newer) will need to install a more up-to-date version. This is easily done via the Python Package Index:
NASM version 2.14 or newer is required for AVX-512 support. See the NASM section for how to install/build. Alternatively, disable AVX-512 in Meson setup with -Denable_avx512=false .
libvmaf
Library for calculating the VMAF video quality metric. Requires ffmpeg to be configured with —enable-libvmaf . Currently an issue in libvmaf also requires FFmpeg to be built with —ld=»g++» for a static build to succeed.
FFmpeg
Now re-login or run the following command for your current shell session to recognize the new ffmpeg location:
Compilation and installation are now complete and ffmpeg (also ffplay , ffprobe , lame , x264 , & x265 ) should now be ready to use. The rest of this guide shows how to update or remove FFmpeg.
Usage
You can now open a terminal, enter the ffmpeg command, and it should execute your new ffmpeg .
If you need multiple users on the same system to have access to your new ffmpeg , and not just the user that compiled it, then move or copy the ffmpeg binary from
/bin to /usr/local/bin .
Documentation
If you want to run man ffmpeg to have local access to the documentation:
You may have to log out and then log in for man ffmpeg to work.
HTML formatted documentation is available in
You can also refer to the online FFmpeg documentation, but remember that it is regenerated daily and is meant to be used with the most current ffmpeg (meaning an old build may not be compatible with the online docs).
Updating FFmpeg
Development of FFmpeg is active and an occasional update can give you new features and bug fixes. First you need to delete (or move) the old files:
Now can just follow the guide from the beginning.
Reverting Changes made by this Guide
Remove the build and source files as well as the binaries:
You may also remove packages that have been installed from this guide:
Why install to
- Avoids installing files into any system directories.
- Avoids interfering with the package management system.
- Avoids conflicts with the ffmpeg package from the repository.
- Super simple to uninstall.
- Does not necessarily require sudo or root: useful for shared server users as long as they have the required dependencies available.
/bin is already in the vanilla Ubuntu PATH (see
/.profile ).
Why are the commands in this guide so complicated?
It is to make compiling easy and convenient for the user. This guide:
- Confines everything to the user’s home directory (see the previous FAQ question above).
- Is intended to be usable on all currently supported versions of Debian and Ubuntu.
- Allows the user to choose if they want to compile certain libraries (latest and greatest) or to simply install the version from their repository (fast and easy but older).
This results in some various additional commands and configurations instead of the typical and simple ./configure , make , make install .
make[1]: Nothing to be done for ‘all’/’install’
This is message from libvpx that occasionally makes users think something went wrong. You can ignore this message. It just means make is finished doing its work.
If You Need Help
Feel free to ask your questions at the #ffmpeg IRC channel or the ffmpeg-user mailing list.
Источник
How to Install FFmpeg in Linux
FFmpeg is one of the best multimedia frameworks that contains various tools for different tasks. For example, the ffplay is a portable media player that can be used to play audio/video files, ffmpeg can convert between different file formats, ffserver can be used to stream live broadcasts and ffprobe is able to analyze multimedia stream.
This framework is really powerful due to the diversity of available tools, that provide the best technical solution for the user. According to the description of FFmpeg on the official website, the reason for having such a great multimedia framework is the combination of the best free software options available.
The FFmpeg framework offers high security and the reason for this is the seriosity of the developers when they review the code, it is always done with security in mind.
I am very sure you will find this framework very useful when you would like to do some digital audio and video streaming or recording. There are many other practical things that you can do with the help of the FFmpeg framework such as converting your wav file to an mp3 one, encode and decode your videos, or even scale them.
According to the official website, FFmpeg is able to do the following.
- decode multimedia files
- encode multimedia files
- transcode multimedia files
- mux multimedia files
- demux multimedia files
- stream multimedia files
- filter multimedia files
- play multimedia files
Let me take an example, a very simple one. The following command will convert your mp4 file into an avi file, simple as that.
The above command is only useful for explanation, it is not recommended to be used in practice because the codec, bitrate, and other specifics are not declared.
In the next part, we will practice with some of the FFmpeg multimedia framework tools, but before doing that we have to install them in our Linux box.
How to Install FFmpeg Multimedia Framework in Linux
Since the FFmpeg packages are offered for the most used Linux distributions and the installation will be relatively easy. Let’s start with the installation of the FFmpeg framework in Ubuntu-based distributions.
Install FFmpeg on Ubuntu and Linux Mint
I will install FFmpeg from the default repositories. Open a new terminal (CTRL+ALT+T) and then run the following commands.
Install FFmpeg on Debian
The FFmpeg package is included in the official Debian repositories and can be installed using the package manager as shown.
Install FFmpeg on CentOS and RHEL
To install FFmpeg on CentOS and RHEL distributions, you need to enable EPEL and RPM Fusion repository on the system using the following commands.
To install and enable EPEL, use the following command.
To install and enable RPM Fusion, use the following command on your distribution version.
After enabling repositories, run the following command to install FFmpeg:
Install FFmpeg on Fedora
On Fedora, you need to install and enable RPM Fusion to install FFmpeg as shown.
Install FFmpeg on Arch Linux
Install FFmpeg on openSUSE
FFmpeg Compiling from Source
Compiling software from a source is not the easiest thing in the world, but with the right instructions, we will be able to do it. First, make sure your system meets all the dependencies. The installation of these dependencies can be done with the help of the following commands.
First, tell the system to pull down the latest packages.
Install the dependencies with the following command.
Then use the following command to create a new directory for the FFmpeg sources. This is the directory where the source files will be downloaded.
Now compile and install yasm assembler used by FFmpeg by running the following commands.
After you have successfully installed the yasm assembler it is time to install some various encoders that will be used with the specific FFmpeg tools. Use the following commands to install the H.264 video encoder.
Another nice useful encoder is the libfdk-aac AAC audio encoder.
Install libopus audio decoder and encoder.
Now, it’s time to install ffmpeg from the source.
Note: If you have not installed certain encoders, make sure to remove ‘–enable-encoder_name‘ from the above ‘./configure‘ command so the installation is done without any problem.
There are many encoders that you can install, but fur the purpose of this article I am not going to install all of them, but you can install them using the following official guides.
Conclusion
In this first part, we updated our readers with the latest news according to the FFmpeg multimedia framework and showed them how to install it on their Linux machines. The next part will be totally about learning how to use the amazing tools inside this leading multimedia framework.
Update: Part 2 of this FFmpeg series is published, which shows some useful ffmpeg command-line usage to perform various audio, video, and image conversion procedures: 15 Useful ‘FFmpeg’ Commands for Video, Audio and Image Conversion in Linux.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Related Posts
11 thoughts on “How to Install FFmpeg in Linux”
Please guide me on how to install ffmpeg in cloudlinux server because I am using cloud Linux in my server.
Run the following commands to Install FFmpeg on CloudLinux OS.
This is mani, when I was trying to install the FFMPEG tool in Redhat 7.6, I am getting Library errors.
Hey, this article is informative but here I want to know how to Set the FFmpeg path and where to?
I can’t fetch update from this repo ‘ppa:mc3man/trusty-media‘.
My environment : Ubuntu 19.04
E: The repository ‘http://ppa.launchpad.net/mc3man/trusty-media/ubuntu disco Release’ does not have a Release file.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
The PPA does not support your version of Ubuntu, better install FFMPEG from default repositories.
Make sure to remove the added PPA:
hello..the above tutorials for ffmpeg wont work with atrpms repository for centos 7…since atrpms server is dead..its no longer available..
one can download the above commands by enabling nux desktop repository explicitely..
sudo yum -y –enablerepo=rpmforge install ffmpeg ffmpeg-devel
and also to the above dependency packegaes
Thank you for the post. You can add here some additional libs and codecs for ffmpeg support all kind of audio and video formats like listed here – http://sysadm.pp.ua/linux/video-streaming/ffmpeg-build.html .
I am trying to use Clip Bucket with FFPMEG conversion, but the script sent the parm ‘- aspect 0’, but the FFMPEG 2.2.4 do not recognize it.
Some technicians talked to me for downgrade to FFMPEG 0.9.1. However, I want to use newest version.
Look my problem:
Converting Video
Conversion Command : /usr/bin/ffmpeg -i /files/conversion_queue/140413494554888.mp4 -f flv -vcodec libx264 -preset normal -r 25 -s 0x0 -aspect 0 -vf pad=0:0:0:0:black -acodec libfaac -ab 128000 -an /files/videos/140413494554888.flv 2> /files/temp/140413500190db3.tmp
ffmpeg version 2.2.4- http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2014 the FFmpeg developers
built on Jun 24 2014 20:49:40 with gcc 4.9 (Debian 4.9.0-7)
configuration: –enable-gpl –enable-version3 –disable-shared –disable-debug –enable-runtime-cpudetect –enable-libmp3lame –enable-libx264 –enable-libwebp –enable-libspeex –enable-libvorbis –enable-libvpx –enable-libfreetype –enable-fontconfig –enable-libxvid –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvo-aacenc –enable-libvo-amrwbenc –enable-gray –enable-libopenjpeg –enable-libopus –disable-ffserver –enable-libass
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘/files/conversion_queue/140413494554888.mp4’:
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isomiso2avc1
creation_time : 2013-12-25 18:45:13
Duration: 00:00:10.29, start: 0.000000, bitrate: 817 kb/s
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640×360, 700 kb/s, 30.11 fps, 30.11 tbr, 30107 tbn, 60214 tbc (default)
Metadata:
creation_time : 2013-12-25 18:45:12
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
creation_time : 2013-12-22 22:48:57
Invalid aspect ratio: 0
Conversion failed!
Where is Part 2 of this article as promised? And why do you keep repeating Part 1?
The part 2 of this series, will be published soon. The author (Oltjano Terpollari) having some serious personal issues, due to this, he may not getting time to publish the 2nd part of this series. And we not repeating it, we updating the article based on newer ffmpeg release. Please co-operate with us, will soon publish a remain part of this portion.
Got something to say? Join the discussion. Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Источник