When a media file needs a container change, a quick audio extract, or a codec check from the terminal, FFmpeg is usually the tool underneath the workflow. Ubuntu carries the ffmpeg package in the Universe component, so most users can install FFmpeg on Ubuntu Linux with APT and keep it updated through normal system upgrades.
Ubuntu 26.04 LTS (Resolute Raccoon), 24.04 LTS (Noble Numbat), and 22.04 LTS (Jammy Jellyfish) all use the same APT package name, including Ubuntu Server and minimal installs once Universe is enabled. The package also installs ffprobe for media inspection and ffplay for quick playback tests. The FFmpeg download page publishes source tarballs and links static Linux builds, but those are not Ubuntu APT packages; use the optional source-build path only when you need a newer upstream branch or custom codec flags.
Install FFmpeg on Ubuntu Linux with APT
Use the Ubuntu repository package unless you have a specific reason to build FFmpeg yourself. The package name is ffmpeg, and it may not be present on every default desktop, server, or minimal install. A PPA is not required for normal installs on Ubuntu 26.04, 24.04, or 22.04.
| Ubuntu Release | Default APT Candidate | Repository Component | Best For |
|---|---|---|---|
| Ubuntu 26.04 LTS (Resolute) | 7:8.0.1-3ubuntu2 (FFmpeg 8.0.x) | Universe | New deployments that want the newest Ubuntu-packaged FFmpeg branch |
| Ubuntu 24.04 LTS (Noble) | 7:6.1.1-3ubuntu5 (FFmpeg 6.1.x) | Universe | Production systems that want the current LTS package branch |
| Ubuntu 22.04 LTS (Jammy) | 7:4.4.2-0ubuntu0.22.04.1 (FFmpeg 4.4.x) | Universe | Older Jammy systems pinned to the 22.04 multimedia stack |
A PPA is not needed just to install FFmpeg. Older PPA instructions, including FFmpeg 4.x PPA examples for Ubuntu 24.04, can complicate package sources without improving the normal APT install path.
Refresh the package index and apply any pending upgrades before installing new software:
sudo apt update && sudo apt upgrade
These commands use
sudofor administrative tasks. If your account does not have sudo privileges yet, follow this guide to add a new user to sudoers on Ubuntu Linux.
Install FFmpeg from Ubuntu’s repositories:
sudo apt install ffmpeg
Check the installed version to confirm the command 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
Ubuntu 24.04 and 22.04 show older branch numbers in this output. If the version looks newer than your Ubuntu package branch, a source build in
/usr/local/binmay be taking priority over/usr/bin/ffmpeg.
Check the package source and candidate version with APT:
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
Update FFmpeg with APT
For normal package updates, use the same system upgrade workflow as the rest of Ubuntu:
sudo apt update
sudo apt upgrade
To upgrade only FFmpeg when a newer package is available, use --only-upgrade:
sudo apt install --only-upgrade ffmpeg
If you plan to compile software against FFmpeg libraries, install the development headers too:
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
Enable Universe If APT Cannot Find FFmpeg
Standard Ubuntu installs normally have Universe enabled. Minimal, cloud, or heavily customized systems may not, which can cause APT to report that it cannot locate the ffmpeg package.
sudo apt install software-properties-common
sudo add-apt-repository -y universe
sudo apt update
After enabling Universe, rerun the sudo apt install ffmpeg command. For more background on Ubuntu archive components, see the guide to enable Universe and Multiverse on Ubuntu.
Compile FFmpeg from Source on Ubuntu Linux (Optional)
Use a source build only when Ubuntu’s packaged branch is too old for a specific codec, filter, or custom compile flag. This method installs FFmpeg under a versioned /usr/local/ffmpeg-<version> prefix and uses /usr/local/ffmpeg-current plus command symlinks, so the cleanup path stays explicit.
A source install under
/usr/local/binusually takes priority over Ubuntu’s packaged binary in/usr/bin. Keep APT as the default method unless you want that newer source-built binary to be the command your shell finds first.
This source method still uses sudo because it installs into /usr/local. Third-party no-sudo static binaries are outside this Ubuntu package guide; use them only if you have checked the provider, update path, and codec support yourself.
Install the source-build prerequisites first. The gpg package is included so you can verify FFmpeg’s signed release tarball before extracting it, while libsdl2-dev lets the source build include ffplay.
sudo apt update
sudo apt install build-essential pkg-config nasm yasm ca-certificates curl gpg tar xz-utils libx264-dev libx265-dev libvpx-dev libmp3lame-dev libopus-dev libaom-dev libass-dev libfreetype-dev libvorbis-dev libtheora-dev libsdl2-dev libtool libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev zlib1g-dev
Detect the current stable FFmpeg tarball from the official download page:
mkdir -p "$HOME/ffmpeg-build/src"
cd "$HOME/ffmpeg-build/src"
FFMPEG_TARBALL=$(curl -fsSL https://ffmpeg.org/download.html | grep -oE 'ffmpeg-[0-9]+(\.[0-9]+)+\.tar\.xz' | sed -n '1p')
if [[ -z "$FFMPEG_TARBALL" ]]; then
echo "No stable FFmpeg tarball was found."
exit 1
fi
FFMPEG_VERSION="${FFMPEG_TARBALL#ffmpeg-}"
FFMPEG_VERSION="${FFMPEG_VERSION%.tar.xz}"
echo "Latest stable FFmpeg release: $FFMPEG_VERSION"
Download the tarball, its signature, and FFmpeg’s release signing key. The curl command uses -f to fail on HTTP errors and -S to show error messages when a quiet transfer fails.
curl -fsSLO "https://ffmpeg.org/releases/$FFMPEG_TARBALL"
curl -fsSLO "https://ffmpeg.org/releases/$FFMPEG_TARBALL.asc"
curl -fsSL https://ffmpeg.org/ffmpeg-devel.asc -o ffmpeg-devel.asc
Verify the release signature before extracting the source archive:
gpg --no-default-keyring --keyring ./ffmpeg-release.gpg --import ffmpeg-devel.asc
gpg --no-default-keyring --keyring ./ffmpeg-release.gpg --verify "$FFMPEG_TARBALL.asc" "$FFMPEG_TARBALL"
gpg: Good signature from "FFmpeg release signing key <ffmpeg-devel@ffmpeg.org>" [unknown] Primary key fingerprint: FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8
The [unknown] trust label is normal when you import the key into a temporary keyring. The important checks are the good signature line and the FFmpeg release-key fingerprint.
Extract the verified archive and point ffmpeg-current at that source tree:
tar -xf "$FFMPEG_TARBALL"
ln -sfn "ffmpeg-$FFMPEG_VERSION" ffmpeg-current
Configure, compile, and install the source build into a versioned prefix under /usr/local:
cd "$HOME/ffmpeg-build/src/ffmpeg-current"
./configure \
--prefix="/usr/local/ffmpeg-$FFMPEG_VERSION" \
--disable-static \
--enable-shared \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libmp3lame \
--enable-libopus \
--enable-libaom \
--enable-sdl2 \
--enable-libass \
--enable-libfreetype \
--enable-libvorbis \
--enable-libtheora
make -j"$(nproc)"
sudo make install
sudo ln -sfn "/usr/local/ffmpeg-$FFMPEG_VERSION" /usr/local/ffmpeg-current
for tool in ffmpeg ffprobe ffplay; do
sudo ln -sfn "/usr/local/ffmpeg-current/bin/$tool" "/usr/local/bin/$tool"
done
printf '%s\n' /usr/local/ffmpeg-current/lib | sudo tee /etc/ld.so.conf.d/ffmpeg-local.conf > /dev/null
sudo ldconfig
hash -r
The ldconfig command refreshes the shared-library cache so the source-built FFmpeg binary can find its matching libraries. Confirm that your shell now resolves FFmpeg from /usr/local/bin:
which ffmpeg
ffmpeg -version | head -n 1
ffprobe -version | head -n 1
/usr/local/bin/ffmpeg ffmpeg version 8.1 Copyright (c) 2000-2026 the FFmpeg developers ffprobe version 8.1 Copyright (c) 2007-2026 the FFmpeg developers
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 so future checks reuse the same signed-tarball workflow and versioned /usr/local layout:
cat <<'EOF' > "$HOME/ffmpeg-build/update-ffmpeg.sh"
#!/usr/bin/env bash
set -euo pipefail
SRC_ROOT="$HOME/ffmpeg-build/src"
DOWNLOAD_PAGE="https://ffmpeg.org/download.html"
RELEASE_BASE="https://ffmpeg.org/releases"
KEY_URL="https://ffmpeg.org/ffmpeg-devel.asc"
KEYRING="$SRC_ROOT/ffmpeg-release.gpg"
if [[ "$(id -u)" -eq 0 ]]; then
echo "Run this script as your normal user. It will use sudo only for installation."
exit 1
fi
for cmd in curl gpg grep ldconfig make nproc pkg-config readlink sed sudo tar xz; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Missing required command: $cmd"
exit 1
fi
done
mkdir -p "$SRC_ROOT"
cd "$SRC_ROOT"
echo "Checking current FFmpeg version..."
CURRENT_VERSION=$(ffmpeg -version 2>/dev/null | sed -n '1s/.*version \([0-9][0-9.]*\).*/\1/p' || true)
CURRENT_VERSION=${CURRENT_VERSION:-not-installed}
echo "Current version: $CURRENT_VERSION"
echo "Checking latest stable FFmpeg release..."
FFMPEG_TARBALL=$(curl -fsSL "$DOWNLOAD_PAGE" | grep -oE 'ffmpeg-[0-9]+(\.[0-9]+)+\.tar\.xz' | sed -n '1p')
if [[ -z "$FFMPEG_TARBALL" ]]; then
echo "No stable FFmpeg tarball was found."
exit 1
fi
LATEST_VERSION="${FFMPEG_TARBALL#ffmpeg-}"
LATEST_VERSION="${LATEST_VERSION%.tar.xz}"
echo "Latest stable release: $LATEST_VERSION"
if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then
echo "FFmpeg is already up to date."
exit 0
fi
PREVIOUS_PREFIX=$(readlink -f /usr/local/ffmpeg-current 2>/dev/null || true)
echo "Downloading FFmpeg $LATEST_VERSION..."
curl -fsSLO "$RELEASE_BASE/$FFMPEG_TARBALL"
curl -fsSLO "$RELEASE_BASE/$FFMPEG_TARBALL.asc"
curl -fsSL "$KEY_URL" -o ffmpeg-devel.asc
echo "Verifying release signature..."
gpg --no-default-keyring --keyring "$KEYRING" --import ffmpeg-devel.asc
gpg --no-default-keyring --keyring "$KEYRING" --verify "$FFMPEG_TARBALL.asc" "$FFMPEG_TARBALL"
echo "Extracting source archive..."
rm -rf "ffmpeg-$LATEST_VERSION"
tar -xf "$FFMPEG_TARBALL"
ln -sfn "ffmpeg-$LATEST_VERSION" ffmpeg-current
cd ffmpeg-current
echo "Configuring FFmpeg $LATEST_VERSION..."
./configure \
--prefix="/usr/local/ffmpeg-$LATEST_VERSION" \
--disable-static \
--enable-shared \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libmp3lame \
--enable-libopus \
--enable-libaom \
--enable-sdl2 \
--enable-libass \
--enable-libfreetype \
--enable-libvorbis \
--enable-libtheora
echo "Compiling FFmpeg $LATEST_VERSION..."
make -j"$(nproc)"
echo "Installing FFmpeg $LATEST_VERSION..."
sudo make install
sudo ln -sfn "/usr/local/ffmpeg-$LATEST_VERSION" /usr/local/ffmpeg-current
for tool in ffmpeg ffprobe ffplay; do
sudo ln -sfn "/usr/local/ffmpeg-current/bin/$tool" "/usr/local/bin/$tool"
done
printf '%s\n' /usr/local/ffmpeg-current/lib | sudo tee /etc/ld.so.conf.d/ffmpeg-local.conf > /dev/null
sudo ldconfig
hash -r
FFMPEG_OUTPUT=$(ffmpeg -version | sed -n '1p' || true)
if [[ -z "$FFMPEG_OUTPUT" ]]; then
echo "New FFmpeg did not run; restoring the previous source prefix."
if [[ -n "$PREVIOUS_PREFIX" && -d "$PREVIOUS_PREFIX" ]]; then
sudo ln -sfn "$PREVIOUS_PREFIX" /usr/local/ffmpeg-current
else
sudo rm -f /usr/local/ffmpeg-current /usr/local/bin/ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffplay
fi
sudo ldconfig
exit 1
fi
echo "Update complete."
echo "$FFMPEG_OUTPUT"
EOF
Mark the script as executable with chmod, copy it into your PATH as update-ffmpeg-source, then run that command whenever you want to check for a newer stable FFmpeg release:
chmod +x "$HOME/ffmpeg-build/update-ffmpeg.sh"
sudo install -m 755 "$HOME/ffmpeg-build/update-ffmpeg.sh" /usr/local/bin/update-ffmpeg-source
update-ffmpeg-source
Checking current FFmpeg version... Current version: 8.1 Checking latest stable FFmpeg release... Latest stable release: 8.1 FFmpeg is already up to date.
The update script leaves older
/usr/local/ffmpeg-<version>prefixes in place so you can roll back manually if a new build behaves differently. Remove old prefixes only after confirming the newer build works for your workloads.
Common FFmpeg Commands on Ubuntu Linux
After installation, ffmpeg, ffprobe, and ffplay are available from the same package or source build. These examples cover the first tasks most users test.
| Task | Tool or Flag | Why It Helps |
|---|---|---|
| Inspect a media file | ffprobe | Shows codecs, duration, bit rate, and stream layout before conversion |
| Quick playback test | ffplay | Plays a file without opening a larger media application |
| Container conversion | -c copy | Changes the container without re-encoding compatible streams |
| H.264 re-encode | libx264 | Creates a widely compatible MP4 output |
| MP3 audio extraction | libmp3lame | Exports the audio stream to a common MP3 file |
Inspect Media Details with ffprobe
Use ffprobe when you need to check a file before converting it:
ffprobe -hide_banner input.mp4
The output lists the container, duration, codec names, resolution, frame rate, and audio layout without modifying the file.
Play a File with ffplay
Use ffplay for a quick local playback check after installing FFmpeg:
ffplay input.mp4
If this command opens a playback window, the companion tool installed correctly. On a headless server or SSH-only session, use ffprobe instead because ffplay needs a graphical display.
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, such as H.264 or H.265 video with 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 common balance between file size and sharpness. The -preset medium flag trades encoding speed for compression efficiency. 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. Lower -q:a values keep more quality, and higher values produce smaller files.
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.
Install v4l-utils for Webcam Capture Checks
If your FFmpeg workflow captures from a webcam, capture card, or another Video4Linux device, v4l-utils is a separate Ubuntu package. Install it only when you need tools such as v4l2-ctl to inspect device names and supported formats before writing an FFmpeg capture command.
sudo apt install v4l-utils
Troubleshoot FFmpeg on Ubuntu Linux
Most FFmpeg install problems on Ubuntu come from a missing Universe component, a stale shell cache, or a source build taking priority over the packaged binary.
| Symptom | Likely Cause | Quick Fix |
|---|---|---|
E: Unable to locate package ffmpeg | Universe is disabled or package metadata is stale | Enable Universe and refresh APT |
command not found | Package missing or stale shell cache | Reinstall FFmpeg and run hash -r |
Unknown encoder 'libx264' | Active build missing the encoder library | Check the active binary and reinstall or rebuild |
| Wrong version reported | Source build shadowing APT binary | Check the command path with which ffmpeg |
APT Cannot Locate the FFmpeg Package
If APT cannot find ffmpeg, confirm Universe is enabled and refresh package metadata:
sudo apt install software-properties-common
sudo add-apt-repository -y universe
sudo apt update
sudo apt install ffmpeg
If the command still fails, check whether your APT source file is missing the universe component or whether your mirror is temporarily out of sync.
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 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 similar to 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 from Ubuntu’s packaged build, reinstall the package. If they are missing from a source build, rebuild with the matching --enable-lib* flags after installing the needed development packages.
Hardware encoders such as h264_nvenc are a separate case. Confirm the system has a working NVIDIA driver and supported GPU before treating FFmpeg as broken; the source build above is validated for common software encoders, not vendor GPU driver stacks. If the driver is missing, start with the guide to install NVIDIA drivers on Ubuntu.
sudo apt install --reinstall ffmpeg
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 rerun 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 build in the cleanup section below and refresh your shell cache with hash -r.
Remove FFmpeg from Ubuntu Linux
If you no longer need FFmpeg, remove the APT package first. Preview autoremove before running it, especially on systems where other multimedia tools are installed, and skip the cleanup if it lists packages you still want to keep.
sudo apt remove ffmpeg
sudo apt autoremove --dry-run
If the preview only lists packages you are ready to remove, run the real cleanup command:
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 the package is no longer installed with an installed-state check:
dpkg -l ffmpeg | grep '^ii' || echo "ffmpeg package is not installed"
ffmpeg package is not installed
If you want to confirm that the repository package still exists after removal, use APT policy as a separate source and candidate check:
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 article-created source prefixes, command symlinks, linker configuration, and build workspace. Do not run the
/usr/local/ffmpeg-*cleanup if you intentionally keep custom directories with that same naming pattern.
sudo rm -f /usr/local/bin/ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffplay /usr/local/bin/update-ffmpeg-source
sudo rm -f /usr/local/ffmpeg-current
sudo rm -rf /usr/local/ffmpeg-*
sudo rm -f /etc/ld.so.conf.d/ffmpeg-local.conf
sudo ldconfig
rm -rf "$HOME/ffmpeg-build"
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.
Conclusion
FFmpeg is available on Ubuntu through the lower-maintenance APT package or a custom source build when you need newer upstream codec work. The APT package covers ffmpeg, ffprobe, ffplay, and common software encoders. For GUI transcoding, add HandBrake on Ubuntu; for playback testing, pair it with VLC on Ubuntu or MPV on Ubuntu.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>