How to Install FFmpeg on Ubuntu?
How to Install FFmpeg on Ubuntu 24
FFmpeg is a powerful open-source command-line tool used for processing audio and video files. It allows you to convert, compress, record, and stream multimedia content. If you're working on media projects or building applications that handle video/audio, FFmpeg is an essential utility.
In this guide, we'll walk you through how to install FFmpeg on Ubuntu and verify it’s working correctly.
Prerequisites
Before you start, ensure:
- You have an Ubuntu system (Ubuntu 18.04, 20.04, 22.04 or newer)
- You have sudo/root access
Method 1: Install FFmpeg from Ubuntu’s Official Repositories
This is the easiest and most reliable method for most users.
Step 1: Update Your Package List
sudo apt updateStep 2: Install FFmpeg
sudo apt install ffmpeg -yThis command will install FFmpeg along with all necessary dependencies.
Step 3: Verify the Installation
After installation, run:
ffmpeg -versionYou should see output similar to this:
ffmpeg version 4.x Copyright ...This confirms FFmpeg is installed and ready to use.
Method 2: Install the Latest FFmpeg Version from Source
Ubuntu’s repositories may not always include the latest version. To get the most up-to-date features, you can build FFmpeg from source.
Step 1: Install Required Build Tools and Libraries
sudo apt update
sudo apt install -y autoconf automake build-essential cmake git libtool pkg-config texinfo zlib1g-devInstall additional libraries for video/audio support:
sudo apt install -y libx264-dev libx265-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev libass-dev libfreetype6-devStep 2: Clone FFmpeg Source Code
cd ~
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpegStep 3: Configure and Build FFmpeg
./configure \
--enable-gpl \
--enable-nonfree \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libass \
--enable-libfreetype
make -j$(nproc)
sudo make installStep 4: Verify the Build
Run:
ffmpeg -versionThis should now display the latest version of FFmpeg you just built.
Optional: Install FFmpeg Development Packages
If you are developing software that depends on FFmpeg, install the development libraries:
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-devTest FFmpeg
To ensure FFmpeg is working, try a simple conversion:
ffmpeg -i input.mp4 output.aviThis will convert an MP4 video to AVI format.
Conclusion
Installing FFmpeg on Ubuntu is straightforward using the official repositories, but you can also build from source if you need the latest version or specific features.
Whether you're compressing videos, extracting audio, or streaming media, FFmpeg is an essential tool for any multimedia workflow on Ubuntu.