Install FFmpeg 5 on Ubuntu 22.04 LTS – No Extra Dependencies Needed
A couple of hours ago a colleague tried to transcode a 4K clip after an accidental driver downgrade. The command line returned “unknown codec” because the pre‑installed FFmpeg 4 was missing libx264 support. Upgrading to FFmpeg 5 on Ubuntu 22.04 LTS fixes that and gives access to the newest codecs with minimal fuss.
Why use FFmpeg 5 instead of the stock package?
Ubuntu’s repositories ship FFmpeg 4, which lacks many modern formats. The official 5.x build from the FFmpeg PPA includes libx264, libx265, and the NVENC libraries that most power users rely on for hardware‑accelerated encoding.
Step 1 – Clean up older FFmpeg packages
If a previous attempt left behind broken files, start fresh:
sudo apt purge ffmpeg libav-tools
Removing the stock version prevents conflicts with the new binaries and clears space for the PPA’s dependencies.
Step 2 – Add the official FFmpeg PPA
The FFmpeg team maintains a stable Personal Package Archive that tracks the latest releases. Adding it is one line:
sudo add-apt-repository ppa:jonathonf/ffmpeg-5
Why this matters: The PPA guarantees that apt pulls the exact 5.x build rather than a backported or older version.
Step 3 – Update package lists
After adding any repository, refresh the cache:
sudo apt update
Skipping this step would lead to “Package not found” errors when you try to install.
Step 4 – Install FFmpeg 5
Now pull in the full suite of codecs:
sudo apt install ffmpeg
This pulls ffmpeg, libavformat-dev, and all runtime libraries required for decoding, encoding, and filtering. The installation completes in a few minutes on a typical laptop.
Step 5 – Verify the build
Confirm you’re actually running FFmpeg 5:
ffmpeg -version | head -n 1
You should see something like ffmpeg version n5.x. If it still reports an older version, double‑check that no other package shadows the binary (which ffmpeg should point to /usr/bin/ffmpeg).
Quick sanity test
Try encoding a short clip with hardware acceleration:
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp4
If you receive “Unknown encoder: h264_nvenc”, the NVENC libraries weren’t installed, meaning the PPA didn’t finish properly. Re‑run the apt install ffmpeg step and try again.
Keep it tidy
When you’re done or if you want to rollback:
sudo apt purge ffmpeg
sudo add-apt-repository --remove ppa:jonathonf/ffmpeg-5
This leaves your system exactly as before without lingering dependencies.
That’s all. With the official PPA, installing FFmpeg 5 on Ubuntu 22.04 LTS is a one‑liner that gives you the latest codecs and hardware acceleration right out of the box—no compiling or fiddling with source needed.