You can install FFmpeg on Ubuntu using the official APT repository, the Snap package store, or by compiling it directly from the official source code.
FFmpeg is a highly popular, open-source command-line framework used for converting (transcoding), recording, editing, and streaming audio and video files. It supports almost every media format and codec in existence. When you install the core package, you also get ffprobe for analyzing media streams and ffplay for quick video playback directly from the command line.
This guide provides clear terminal instructions for all three installation paths, compares their characteristics, and outlines how to run hardware-accelerated encodings on Ubuntu 24.04 and 26.04 LTS. If you run into any setup issues, feel free to drop a comment below or contact us directly for support. We are always here to help you get it running.
APT, Snap & Source Code Setup Guides
Configure FFmpeg on your Ubuntu workstation or server. Compare package repository stability against containerized formats, and run verified CLI commands and scripts.
Choosing the correct installation path determines the specific codecs available to your system, the freshness of your FFmpeg binary, and how updates are configured. Below is an analytical look at the available options to help you choose the best installation path.
FFmpeg Installation Methods Compared
Use the comparison table below to weigh package freshness, configuration flexibility, security boundaries, and update methods before running the setup commands.
| Method | Version Age | Auto-Updates | Security Isolation | Best For |
|---|---|---|---|---|
| Official APT (Recommended) | Distribution Stable (e.g. v6.x or v7.x) | System updates (via apt upgrade) | No (unconfined system access) | Server environments, basic transcoding, and scripting |
| Snap Package | Latest Upstream Stable | Automatic (via snapd service) | Yes (strictly confined sandbox) | Accessing new codec features without manual compilation |
| Source Compiling | Custom (up to latest Git snapshot) | Manual rebuild needed | No (unconfined system access) | Adding custom codecs (e.g. non-free fdk-aac) or patches |
Method 1: Install FFmpeg via the Official APT Repository (Recommended)
The standard way to install FFmpeg on Ubuntu is using the default APT package manager. Ubuntu hosts the stable distribution release of FFmpeg in its Universe repository. This packaged format is thoroughly tested for compatibility, integrates cleanly with system libraries, and receives security updates automatically during system upgrades. When you install the core package, Ubuntu also installs helper commands like ffprobe and ffplay.
Open a terminal window (Ctrl+Alt+T). Run the update command to synchronize your system’s package database with Ubuntu’s remote repositories:
sudo apt update
Install the core package. This command will download and unpack the main binary along with required audio and video libraries:
sudo apt install ffmpeg -y
Verify that the binaries are correctly registered to your system path by checking the active version number:
ffmpeg -version
Method 2: Install FFmpeg via the Snap Package Manager
If you require a newer upstream version of FFmpeg than what is provided by your Ubuntu release repositories, the official Snap package is an excellent alternative. Snaps are containerized packages managed by the Canonical snapd service. They run inside a secure sandbox (strict confinement), keeping the application’s processes and media files isolated from the rest of your system. Snaps automatically update in the background, ensuring you always have the latest codecs and bug fixes.
Install the stable release of FFmpeg directly from the Snapcraft catalog:
sudo snap install ffmpeg
Because Snap applications are strictly sandboxed, the installed FFmpeg command cannot access files outside its package container. If you attempt to process videos in your home directory or external hard drives, you will get Permission denied errors. Run these two commands to connect the necessary interface plugs:
# Allow access to your home directory (~/) files sudo snap connect ffmpeg:home # Allow access to removable USB drives or external storage sudo snap connect ffmpeg:removable-media
Method 3: Compile FFmpeg from Source (Advanced Users)
For advanced users who need to customize specific features (compilation flags), include proprietary codecs (like the high-quality fdk-aac audio encoder), or test the latest development versions, compiling FFmpeg from source is the best approach. This process builds the executable specifically for your CPU architecture, maximizing performance.
1. Install the Build Environment and Codecs:
Install development dependencies, assembler libraries (yasm/nasm), and codec development headers:
sudo apt update
sudo apt install -y build-essential yasm nasm git wget \
libx264-dev libx265-dev libvpx-dev libfdk-aac-dev \
libmp3lame-dev libopus-dev libass-dev libvorbis-dev
2. Fetch the Latest Source Archive:
Create a local build directory, download the official source snapshot, and unpack it:
mkdir -p ~/ffmpeg_sources cd ~/ffmpeg_sources wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 tar xjvf ffmpeg-snapshot.tar.bz2 cd ffmpeg/
3. Configure the Build Settings:
Run the configure script. We will explicitly enable the major open-source codecs, enable the GPL/non-free licenses (necessary for certain libraries like fdk-aac), and set the installation path prefix to `/usr/local` so it does not conflict with system packages:
./configure --prefix=/usr/local \
--enable-gpl \
--enable-nonfree \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libass \
--enable-libvorbis
4. Compile and Link:
Compile the code using all available CPU threads (`$(nproc)`) and install the binary libraries to your local path:
make -j$(nproc) sudo make install
5. Reload Local Path Configuration:
Reload your system’s library cache to ensure the shell resolves your newly compiled local binaries:
hash -r ffmpeg -version
The FFmpeg Media Transcoding Pipeline
To make sense of FFmpeg’s command-line structures, it helps to understand what is happening inside this pipeline:
- Demuxing and Muxing: Splitting or joining audio and video streams inside a container file (such as
.mp4or.mkv). - Decoding and Encoding: Uncompressing video data into raw frames so you can edit them, and then re-compressing them back into a new format.
- Filtering: Applying visual changes, such as resizing (scaling), rotating, or overlaying text.
Configuring GPU Hardware Acceleration on Ubuntu
Transcoding high-resolution video streams on your CPU can put a heavy load on your processor. You can optimize this by utilizing your GPU for hardware-accelerated encoding and decoding. The default Ubuntu installation of FFmpeg includes support for the major hardware acceleration frameworks out of the box.
For systems running Intel or AMD integrated/dedicated graphics, use the Video Acceleration API (VA-API). First, ensure the acceleration drivers are installed on your Ubuntu system:
# Install VA-API runtime drivers sudo apt install -y va-driver-all vainfo
Verify support by running `vainfo`. To execute a GPU-accelerated video conversion to H.264 using VA-API, structure your command like this:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
-i input.mp4 -c:v h264_vaapi -vf "scale_vaapi=1920:1080" output.mp4
For workstations or servers equipped with NVIDIA GPUs, offload video encoding to the dedicated NVENC chip. First, verify that you have the official proprietary NVIDIA drivers installed (open Additional Drivers in Ubuntu or run `nvidia-smi` in the terminal). Convert a video file quickly using NVIDIA acceleration with this command:
ffmpeg -i input.mp4 -c:v h264_nvenc -preset slow -cq:v 23 output.mp4
7 Practical FFmpeg Command-Line Examples
FFmpeg’s utility lies in its command-line arguments. Review these common, highly useful tasks that address daily media manipulation needs.
Speed: Nearly instant (no quality loss).
ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4
Best for: Web sharing and archiving.
ffmpeg -i input.mp4 -c:v libsvtav1 -crf 26 -preset 4 -c:a libopus output.mp4
Quality: High-quality variable bitrate.
ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3
Time range: 30s to 2min 15s.
ffmpeg -ss 00:00:30 -to 00:02:15 -i input.mp4 -c copy output.mp4
Filter: Lanczos scaling.
ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Framerate: 30 FPS.
ffmpeg -f x11grab -video_size 1920x1080 -framerate 30 -i :0.0 output.mp4
Audio: AAC format.
ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
Graphical Alternatives: Installing a GUI for FFmpeg
If you prefer working with a graphical user interface rather than running commands in the terminal, several powerful open-source media conversion tools provide a visual desktop front-end around FFmpeg’s encoding libraries. Below are the two most recommended and actively maintained GUI alternatives for Ubuntu:
Install via APT:
sudo apt install handbrake -y
Install downloaded .deb package:
sudo apt install ./ShutterEncoder-*.deb
How to Uninstall FFmpeg from Ubuntu
If you need to remove FFmpeg or reset system libraries to default configurations, run the commands corresponding to your installation method.
1. For the Native APT and GUI Methods:
Remove the core packages and graphical desktop interfaces, then automatically clean up unused configuration dependencies:
# Remove FFmpeg, HandBrake, or Shutter Encoder packages sudo apt purge -y ffmpeg handbrake shutter-encoder sudo apt autoremove -y
2. For the Snap Method:
Uninstall the Snap package and clear related environment settings:
sudo snap remove ffmpeg
3. For the Compiled Source Method:
Navigate to your local source compilation folder, invoke the local uninstallation hook, and purge build folders:
cd ~/ffmpeg_sources/ffmpeg/ sudo make uninstall make distclean rm -rf ~/ffmpeg_sources
Helpful Resources for FFmpeg Users
To assist with troubleshooting, advanced codec tuning, or complex command structures, consult the following community links:
Frequently Asked Questions
What is the recommended method to install FFmpeg on Ubuntu?
The recommended method for most users is using the APT package manager to install the official package from the Ubuntu repositories. This is the most stable and secure option, integrating directly with regular system updates.
How do I fix permission denied errors in the Snap version of FFmpeg?
By default, Snap packages run in a sandbox. To grant FFmpeg permission to access your files, run the connection commands: sudo snap connect ffmpeg:home and sudo snap connect ffmpeg:removable-media in your terminal.
Why should I compile FFmpeg from source on Ubuntu?
Compiling from source is recommended if you require the absolute latest release version, a custom codec configuration, or third-party libraries (like fdk-aac) that are not bundled with pre-compiled distribution packages due to licensing terms.
Does the default Ubuntu FFmpeg package support hardware acceleration?
Yes. The official APT package includes support for VA-API (Intel and AMD graphics) and NVENC (NVIDIA graphics) out of the box, allowing you to offload transcoding tasks to your GPU.
What is the difference between ffmpeg, ffplay, and ffprobe?
FFmpeg is the main CLI tool used to convert, stream, and process media. FFprobe is a utility for inspecting media stream details (codecs, bitrates, resolutions). FFplay is a simple, lightweight media player for quick command-line playback.
More Ubuntu guides: Install Docker on Ubuntu · Docker Compose Guide · How to Play DVDs on Ubuntu
