Most video conversion, audio extraction, and streaming workflows on Linux run through FFmpeg at some point. Ubuntu ships it in the default Universe repository, so you can install FFmpeg on Ubuntu Linux with a single APT command and keep it updated alongside the rest of your system.
Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS all carry FFmpeg in their default repositories. Anyone who needs a newer upstream release or custom build flags can compile from source instead, with an update script to simplify future rebuilds.
Install FFmpeg on Ubuntu Linux with APT
Ubuntu ships FFmpeg in the Universe repository, so most systems can install it directly without adding third-party sources.
| Ubuntu Release | Default FFmpeg | Support Window | Best For |
|---|---|---|---|
| Ubuntu 26.04 LTS | FFmpeg 8.0.x | Standard support through 2031 | New deployments needing the latest Ubuntu-packaged FFmpeg features |
| Ubuntu 24.04 LTS | FFmpeg 6.1.x | Standard support through 2029 | Production systems balancing feature set and stability |
| Ubuntu 22.04 LTS | FFmpeg 4.4.x | Standard support through 2027 | Legacy stacks pinned to Jammy-era multimedia libraries |
For most users, the Ubuntu repository is the recommended method because it is straightforward, receives security updates through APT, and avoids maintenance overhead from custom builds.
Refresh the package index and apply any pending upgrades before installing new software:
sudo apt update && sudo apt upgrade
This guide uses
sudofor administrative commands. If your account does not have sudo privileges yet, follow this guide to add a new user to sudoers on Ubuntu Linux.
Install the FFmpeg package, which pulls in codec libraries for H.264, H.265, AV1, VP9, and more:
sudo apt install ffmpeg
Check the installed version to confirm FFmpeg is working:
ffmpeg -version
ffmpeg version 8.0.1-3ubuntu2 Copyright (c) 2000-2025 the FFmpeg developers configuration: --prefix=/usr --extra-version=3ubuntu2 --enable-gpl --enable-libx264 --enable-libx265 --enable-libaom ... libavutil 60. 8.100 / 60. 8.100 libavcodec 62. 11.100 / 62. 11.100 libavformat 62. 3.100 / 62. 3.100
If this version output does not match your Ubuntu package branch, you probably still have a source build in
/usr/local/bin/ffmpeg. Check withwhich ffmpegand compare against/usr/bin/ffmpeg -versionto confirm what APT installed.
Double-check which repository the package came from and whether APT sees a newer candidate:
apt-cache policy ffmpeg
ffmpeg:
Installed: 7:8.0.1-3ubuntu2
Candidate: 7:8.0.1-3ubuntu2
Version table:
*** 7:8.0.1-3ubuntu2 500
500 http://archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
100 /var/lib/dpkg/status
If you run Ubuntu 24.04 LTS or 22.04 LTS, the command output follows the same format but reports the release-specific package versions from those repositories. You can check package details for each release at Ubuntu Packages: FFmpeg.
If you plan to build software against FFmpeg libraries, install the development headers as well:
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
Compile FFmpeg from Source on Ubuntu Linux (Optional)
Use this method when you need a newer upstream FFmpeg branch, custom compile flags, or a /usr/local build separate from Ubuntu’s packaged version.
Known gotcha: a source install under
/usr/local/binusually takes precedence over Ubuntu’s APT binary in/usr/bin. If versions look inconsistent later, check withwhich ffmpeg.
Install the source-build prerequisites first:
sudo apt update
sudo apt install build-essential pkg-config nasm yasm libx264-dev libx265-dev libvpx-dev libmp3lame-dev libopus-dev libaom-dev libass-dev libfreetype6-dev libvorbis-dev libtheora-dev libtool libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev zlib1g-dev wget curl git
Use the GitHub API with curl to detect and download the latest stable FFmpeg source tag automatically:
mkdir -p "$HOME/ffmpeg-build/src"
cd "$HOME/ffmpeg-build/src"
FFMPEG_TAG=$(curl -fsSL https://api.github.com/repos/FFmpeg/FFmpeg/tags?per_page=100 | grep -oP '"name": "\Kn[0-9]+\.[0-9]+(\.[0-9]+)?(?=")' | head -n 1)
echo "Latest stable FFmpeg tag: $FFMPEG_TAG"
curl -fL "https://github.com/FFmpeg/FFmpeg/archive/refs/tags/${FFMPEG_TAG}.tar.gz" -o "ffmpeg-${FFMPEG_TAG}.tar.gz"
tar -xzf "ffmpeg-${FFMPEG_TAG}.tar.gz"
ln -sfn "FFmpeg-${FFMPEG_TAG}" ffmpeg-current
Latest stable FFmpeg tag: n8.0.1
Run ./configure to enable the codecs you need, then compile with all available CPU cores and install to /usr/local:
cd "$HOME/ffmpeg-build/src/ffmpeg-current"
./configure \
--prefix=/usr/local \
--disable-static \
--enable-shared \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libmp3lame \
--enable-libopus \
--enable-libaom \
--enable-libass \
--enable-libfreetype \
--enable-libvorbis \
--enable-libtheora
make -j"$(nproc)"
sudo make install
sudo ldconfig
hash -r
The ldconfig command refreshes the shared library cache so the system finds the new FFmpeg libraries. The hash -r command clears your shell’s path lookup cache so it picks up the new binary location. Confirm the binary your shell resolves:
which ffmpeg
ffmpeg -version | head -n 1
/usr/local/bin/ffmpeg ffmpeg version 8.0.1 Copyright (c) 2000-2025 the FFmpeg developers
When both APT and source builds are installed,
/usr/local/bin/ffmpegusually takes precedence over/usr/bin/ffmpeg. Usewhich ffmpegwhenever version behavior seems inconsistent.
Create an Update Script for Source-Compiled FFmpeg
Source builds do not update through APT. Create this script at $HOME/ffmpeg-build/update-ffmpeg.sh to check for new stable tags and rebuild automatically when a newer version is available:
cat <<'EOF' > "$HOME/ffmpeg-build/update-ffmpeg.sh"
#!/usr/bin/env bash
set -euo pipefail
# Paths used by this guide
SRC_ROOT="$HOME/ffmpeg-build/src"
SRC_LINK="$SRC_ROOT/ffmpeg-current"
echo "Checking currently installed FFmpeg version..."
CURRENT_VERSION=$(ffmpeg -version 2>/dev/null | head -n 1 | grep -oP 'version \K[0-9]+(\.[0-9]+){1,2}' || echo "not-installed")
echo "Current version: $CURRENT_VERSION"
echo "Fetching latest stable FFmpeg tag from GitHub..."
LATEST_TAG=$(curl -fsSL https://api.github.com/repos/FFmpeg/FFmpeg/tags?per_page=100 | grep -oP '"name": "\Kn[0-9]+\.[0-9]+(\.[0-9]+)?(?=")' | head -n 1)
LATEST_VERSION="${LATEST_TAG#n}"
echo "Latest tag: $LATEST_TAG"
if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then
echo "FFmpeg is already up to date."
exit 0
fi
mkdir -p "$SRC_ROOT"
cd "$SRC_ROOT"
echo "Downloading FFmpeg $LATEST_VERSION..."
curl -fL "https://github.com/FFmpeg/FFmpeg/archive/refs/tags/${LATEST_TAG}.tar.gz" -o "ffmpeg-${LATEST_TAG}.tar.gz"
echo "Extracting source archive..."
tar -xzf "ffmpeg-${LATEST_TAG}.tar.gz"
ln -sfn "FFmpeg-${LATEST_TAG}" ffmpeg-current
cd "$SRC_LINK"
echo "Configuring build..."
./configure \
--prefix=/usr/local \
--disable-static \
--enable-shared \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libmp3lame \
--enable-libopus \
--enable-libaom \
--enable-libass \
--enable-libfreetype \
--enable-libvorbis \
--enable-libtheora
echo "Compiling FFmpeg (this may take several minutes)..."
make -j"$(nproc)"
echo "Installing FFmpeg to /usr/local..."
sudo make install
sudo ldconfig
hash -r
echo "Update complete."
ffmpeg -version | head -n 1
EOF
Mark the script as executable with chmod, then run it to verify the update check works:
chmod +x "$HOME/ffmpeg-build/update-ffmpeg.sh"
"$HOME/ffmpeg-build/update-ffmpeg.sh"
Checking currently installed FFmpeg version... Current version: 8.0.1 Fetching latest stable FFmpeg tag from GitHub... Latest tag: n8.0.1 FFmpeg is already up to date.
Common FFmpeg Commands on Ubuntu Linux
Once FFmpeg is installed, these commands cover the tasks most users perform first.
| Task | Command |
|---|---|
| Container conversion (MKV to MP4) | ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4 |
| Re-encode to H.264 + AAC | ffmpeg -i input.avi -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4 |
| Extract audio to MP3 | ffmpeg -i video.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3 |
| Resize video to 720p | ffmpeg -i input.mp4 -vf "scale=1280:720" -c:a copy output-720p.mp4 |
Convert MKV to MP4 Without Re-encoding
ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4
The -c:v copy -c:a copy flags tell FFmpeg to stream-copy both video and audio without re-encoding, so the conversion is nearly instant and lossless. Stream-copy only works when the source codecs are already MP4-compatible (H.264 or H.265 video, AAC audio). If the source uses incompatible codecs, use the re-encode command below instead.
Re-encode Video with H.264 and AAC
ffmpeg -i input.avi -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4
The -crf 23 flag controls visual quality on a scale from 0 (lossless) to 51 (lowest quality), and 23 is a good balance between file size and sharpness. The -preset medium flag trades encoding speed for compression efficiency. The -b:a 128k flag sets the audio bitrate. Use this command when you need a smaller or more compatible output file.
Extract Audio Track to MP3
ffmpeg -i video.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3
The -vn flag drops the video stream, while -q:a 2 keeps high-quality variable bitrate audio.
Resize Video to 720p
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:a copy output-720p.mp4
For aspect-ratio-safe scaling, replace 1280:720 with 1280:-1 or -1:720.
Troubleshoot FFmpeg on Ubuntu Linux
| Symptom | Likely Cause | Quick Fix |
|---|---|---|
command not found | Package missing or stale shell cache | sudo apt install --reinstall ffmpeg && hash -r |
Unknown encoder 'libx264' | Active build missing the encoder library | Reinstall Ubuntu’s FFmpeg package |
Permission denied | No write access to output directory | Write to a user-owned directory |
| Wrong version reported | Source build shadowing APT binary | Check path with which ffmpeg |
ffmpeg Command Not Found
If FFmpeg is not detected after installation, your package may not have installed correctly or your shell command cache may be stale.
bash: ffmpeg: command not found
Check whether the binary is present on your path:
which ffmpeg
/usr/bin/ffmpeg
If no path is returned, reinstall the package and refresh your shell cache:
sudo apt install --reinstall ffmpeg
hash -r
Verify the fix:
ffmpeg -version | head -n 1
ffmpeg version 8.0.1-3ubuntu2 Copyright (c) 2000-2025 the FFmpeg developers
Unknown Encoder Errors (libx264, libx265, libaom)
This error appears when your active FFmpeg build does not include the encoder you requested.
Unknown encoder 'libx264'
Check which encoders are available in your current FFmpeg binary:
ffmpeg -hide_banner -encoders | grep -E 'libaom-av1|libx264|libx265'
If the encoders are compiled in, you will see lines like these:
V....D libaom-av1 libaom AV1 (codec av1) V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264) V....D libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264) V....D libx265 libx265 H.265 / HEVC (codec hevc)
For more grep filtering tricks, such as case-insensitive search or pattern exclusion, the full command guide covers those options.
If those encoders are missing, reinstall Ubuntu’s FFmpeg package to restore the distro build:
sudo apt install --reinstall ffmpeg
Re-run the grep encoder check above to confirm the libraries are restored.
Permission Denied When Writing Output Files
FFmpeg needs write access to the destination directory. This often happens when saving to system paths without root permissions.
output.mp4: Permission denied
Check who owns the target directory and whether your user has write access:
ls -ld /path/to/output-directory
drwxr-xr-x 2 user user 4096 Mar 1 12:10 /home/user/videos
Write to a directory you own, such as your home folder, then re-run your conversion command.
APT and Source-Build FFmpeg Version Mismatch
If you installed FFmpeg from source and APT on the same system, check which binary your shell is executing before troubleshooting codec behavior.
which ffmpeg
ffmpeg -version | head -n 1
If this reports /usr/local/bin/ffmpeg, you are using the source build. If you want Ubuntu’s packaged version instead, remove the source binaries in the removal section below and refresh your shell cache with hash -r.
Remove FFmpeg from Ubuntu Linux
If you no longer need FFmpeg, remove it with APT and clean unused dependencies.
sudo apt remove ffmpeg
sudo apt autoremove
If you also installed FFmpeg development headers, remove those packages separately:
sudo apt remove libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
Confirm FFmpeg is no longer installed:
apt-cache policy ffmpeg
ffmpeg:
Installed: (none)
Candidate: 7:8.0.1-3ubuntu2
Version table:
7:8.0.1-3ubuntu2 500
500 http://archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
Remove Source-Compiled FFmpeg Files (If Installed)
The following commands permanently remove the source-compiled FFmpeg binaries and build workspace under
$HOME/ffmpeg-build/. Back up any custom build notes or scripts before cleanup.
sudo rm -f /usr/local/bin/ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffplay
rm -rf "$HOME/ffmpeg-build/src" "$HOME/ffmpeg-build/update-ffmpeg.sh"
hash -r
If the APT package is still installed, the system binary should take over automatically:
which ffmpeg
ffmpeg -version | head -n 1
/usr/bin/ffmpeg ffmpeg version 8.0.1-3ubuntu2 Copyright (c) 2000-2025 the FFmpeg developers
If you are troubleshooting path behavior after uninstalling, this primer on the which command in Linux can help you confirm which binary your shell is selecting.
Frequently Asked Questions
Ubuntu 26.04 installs FFmpeg 8.0.x, Ubuntu 24.04 installs FFmpeg 6.1.x, and Ubuntu 22.04 installs FFmpeg 4.4.x from the default Universe repository.
No. Ubuntu already provides FFmpeg in the official Universe repository, so most users can install it directly with apt and keep it updated through normal system upgrades.
Run sudo apt update and sudo apt upgrade for normal updates, or use sudo apt install --only-upgrade ffmpeg when you want to update only FFmpeg.
Yes. Compile from source if you need a newer upstream branch or custom build flags, using the official FFmpeg documentation and current FFmpeg source tags. For most systems, APT remains the lower-maintenance option.
This usually means the package install did not complete correctly or your shell cache is stale. Reinstall with sudo apt install --reinstall ffmpeg, run hash -r, and verify with ffmpeg -version.
Run ffmpeg -i video.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3 to drop the video stream and encode the audio track as a high-quality variable-bitrate MP3. The -q:a 2 flag sets quality (0 is best, 9 is smallest).
Conclusion
FFmpeg is set up on Ubuntu with working H.264, H.265, AV1, and VP9 encoders through either APT or a custom source build. For a GUI transcoding workflow, add HandBrake on Ubuntu. For playback testing, grab VLC on Ubuntu or the lighter MPV on Ubuntu. For recording and streaming, see OBS Studio on Ubuntu, and for audio editing, Audacity on Ubuntu.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>