FFmpeg lets you convert video files between formats, extract audio tracks, compress footage for web delivery, and stream live content to platforms like YouTube or Twitch. Whether you need to batch-convert vacation videos for social media, pull audio from webinars, or build automated media pipelines, FFmpeg handles it from the command line without requiring a graphical application.
Debian includes FFmpeg in its default repositories, providing versions from 4.3 on Debian 11 up to 7.1 on Debian 13. This guide covers installation via APT for quick setup, source compilation for the latest features, and the Deb-Multimedia repository for advanced users. You will learn to verify your installation, convert videos between formats, extract audio, and troubleshoot common encoding issues.
Choose Your FFmpeg Installation Method
Debian offers multiple installation paths: the default repository provides a stable FFmpeg build maintained by Debian security teams, source compilation gives access to the latest upstream releases, and for advanced users, Deb-Multimedia provides pre-built packages with additional codecs.
| Method | FFmpeg Version | Update Method | Best For |
|---|---|---|---|
| Default APT | 7.1.x (Trixie), 5.1.x (Bookworm), 4.3.x (Bullseye) | apt upgrade | Most users; quick setup with security updates |
| Compile from Source | Latest (5.x, 6.x, 7.x, 8.x branches) | Manual update script | Users needing latest features or custom codecs |
| Deb-Multimedia (Advanced) | Latest stable | apt upgrade | Advanced users who accept system-wide changes |
For most video conversion tasks, the default APT method provides a stable, security-maintained FFmpeg installation. The source compilation method suits users who need features from newer releases or require specific codec configurations. The Deb-Multimedia method is only recommended for advanced users who understand the system-wide implications.
These instructions support Debian 13 (Trixie), 12 (Bookworm), and 11 (Bullseye). The APT method works identically across all releases, though FFmpeg versions differ. Source compilation requires more setup but works across all supported Debian versions.
Method 1: Install FFmpeg via Default APT
Update Debian System Packages
Before installing new software, refresh your package cache and apply pending updates. This ensures FFmpeg installs against current library versions and avoids dependency conflicts.
sudo apt update && sudo apt upgrade
Install FFmpeg Package
Debian’s default repositories include FFmpeg with common codecs enabled. Install it using the APT package manager:
sudo apt install ffmpeg
If you plan to compile software that links against FFmpeg libraries, also install the development headers:
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
Verify FFmpeg Installation
After installation, verify FFmpeg is working correctly by checking the version:
ffmpeg -version
Expected output varies by Debian version:
ffmpeg version 7.1.3-0+deb13u1 Copyright (c) 2000-2025 the FFmpeg developers built with gcc 14 (Debian 14.2.0-17) configuration: --enable-gpl --enable-version3 ... libavutil 59. 39.100 / 59. 39.100 libavcodec 61. 19.100 / 61. 19.100 libavformat 61. 7.100 / 61. 7.100
The version numbers reflect your Debian release: Debian 13 ships FFmpeg 7.1.x, Debian 12 provides 5.1.x, and Debian 11 includes 4.3.x. All versions support common video formats, though newer releases add codec improvements and bug fixes.
You can also check which codecs and encoders are available:
ffmpeg -encoders | head -20
Method 2: Compile FFmpeg from Source
Source compilation provides access to the latest FFmpeg releases and allows custom codec configurations. The FFmpeg project maintains multiple active branches (5.x, 6.x, 7.x, 8.x), each receiving security updates and bug fixes.
Compiling from source requires more initial setup and manual updates. Use this method when you specifically need features unavailable in Debian’s packaged version or require codec configurations not possible with the default build.
Install Build Dependencies
FFmpeg compilation requires several development packages. Install the build tools and codec libraries:
sudo apt update
sudo apt install -y autoconf automake build-essential cmake git-core \
libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev \
libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev \
nasm libx264-dev libx265-dev libnuma-dev libvpx-dev libopus-dev libaom-dev libsvtav1enc-dev
These packages provide compilers, assemblers, and codec libraries for building FFmpeg with H.264, H.265, VP8/VP9, AV1 (libaom and SVT-AV1), MP3, Opus, and Vorbis support. FFmpeg includes a built-in AAC encoder, so no additional AAC library is required.
Create Build Directory
Create a dedicated directory for the FFmpeg source code and build artifacts:
mkdir -p ~/ffmpeg_sources ~/ffmpeg_build
Download FFmpeg Source
FFmpeg maintains multiple version branches simultaneously. Each branch receives security updates and bug fixes, but they differ in features and stability:
- 5.x (LTS): Long-term support branch with maximum stability. Best for production servers where reliability matters more than new features.
- 6.x: Previous stable release series. Good balance of proven stability and modern features.
- 7.x (recommended): Current stable release with the latest codec improvements and optimizations. Best choice for most users.
- 8.x: Latest release series with newest features. Fully stable official releases, not development builds.
The following script prompts you to select a version branch, then downloads the latest release from that branch automatically:
cat <<'EOF' | tee ~/ffmpeg_sources/download-ffmpeg.sh
#!/bin/bash
# FFmpeg Download Script
# Downloads the latest release from a specified version branch
set -e
# Prompt for version branch
echo "Available FFmpeg version branches:"
echo " 5 - FFmpeg 5.x (LTS, stable)"
echo " 6 - FFmpeg 6.x (stable)"
echo " 7 - FFmpeg 7.x (current stable)"
echo " 8 - FFmpeg 8.x (latest)"
read -p "Enter version branch (5/6/7/8) [7]: " VERSION_BRANCH
VERSION_BRANCH=${VERSION_BRANCH:-7}
# Validate input
case $VERSION_BRANCH in
5|6|7|8) ;;
*) echo "Invalid version. Using 7.x"; VERSION_BRANCH=7 ;;
esac
echo "Fetching latest FFmpeg ${VERSION_BRANCH}.x release..."
# Get latest release tag from GitHub API
LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/FFmpeg/FFmpeg/tags?per_page=100" | \
grep -oP '"name": "n'"${VERSION_BRANCH}"'\.[0-9]+(\.[0-9]+)?"' | \
head -1 | \
grep -oP 'n[0-9.]+')
if [ -z "$LATEST_TAG" ]; then
echo "Error: Could not find a release for version ${VERSION_BRANCH}.x"
exit 1
fi
echo "Latest release: $LATEST_TAG"
# Download source
cd ~/ffmpeg_sources
DOWNLOAD_URL="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/${LATEST_TAG}.tar.gz"
echo "Downloading from: $DOWNLOAD_URL"
wget -O "ffmpeg-${LATEST_TAG}.tar.gz" "$DOWNLOAD_URL"
# Extract
echo "Extracting source..."
tar xzf "ffmpeg-${LATEST_TAG}.tar.gz"
# Create symlink for convenience
rm -f ffmpeg-current
ln -s "FFmpeg-${LATEST_TAG#n}" ffmpeg-current
echo ""
echo "Download complete!"
echo "Source directory: ~/ffmpeg_sources/ffmpeg-current"
echo "Version: $LATEST_TAG"
EOF
Make the script executable. Linux requires this permission before you can run a script directly:
chmod +x ~/ffmpeg_sources/download-ffmpeg.sh
Run the download script. When prompted, enter a number (5, 6, 7, or 8) to select your version branch, or press Enter to accept the default (7.x):
~/ffmpeg_sources/download-ffmpeg.sh
Available FFmpeg version branches: 5 - FFmpeg 5.x (LTS, stable) 6 - FFmpeg 6.x (stable) 7 - FFmpeg 7.x (current stable) 8 - FFmpeg 8.x (latest) Enter version branch (5/6/7/8) [7]: 7 Fetching latest FFmpeg 7.x release... Latest release: n7.1.3 Downloading from: https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n7.1.3.tar.gz ... Download complete! Source directory: ~/ffmpeg_sources/ffmpeg-current Version: n7.1.3
The script downloads the source code and creates a ffmpeg-current symlink pointing to the extracted directory. This symlink simplifies the compilation commands and makes future updates easier since you always work with ffmpeg-current regardless of the actual version number.
Compile and Install FFmpeg
Configure and compile FFmpeg with commonly used codecs. The -j$(nproc) flag uses all available CPU cores to speed up compilation:
cd ~/ffmpeg_sources/ffmpeg-current
# Configure with common codecs
./configure \
--prefix="$HOME/ffmpeg_build" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="/usr/local/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libass \
--enable-libaom \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libsvtav1 \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265
# Compile using all CPU cores
make -j$(nproc)
# Install to /usr/local/bin
sudo make install
# Update shared library cache
sudo ldconfig
Compilation time depends on your hardware. On a modern multi-core system, expect 5-15 minutes. Older or single-core systems may take significantly longer.
Verify Source-Compiled Installation
Verify the installation:
ffmpeg -version
Look for the --enable-libaom and --enable-libx264 flags in the configuration line to confirm the video encoders are available:
ffmpeg version 7.1.3 Copyright (c) 2000-2025 the FFmpeg developers built with gcc 14 (Debian 14.2.0-19) configuration: --prefix=/home/user/ffmpeg_build --enable-gpl --enable-libaom --enable-libsvtav1 --enable-libx264 --enable-libx265 ... libavutil 59. 39.100 / 59. 39.100 libavcodec 61. 19.100 / 61. 19.100
Create Update Script
Unlike APT packages that update automatically, source-compiled software requires manual updates. The following script checks if a newer FFmpeg version is available, downloads it if so, and recompiles automatically. It prompts you to select which version branch to check (the same options as the download script), compares versions, and only recompiles if an update exists:
cat <<'EOF' | tee ~/ffmpeg_sources/update-ffmpeg.sh
#!/bin/bash
# FFmpeg Update Script
# Checks for updates and recompiles if a newer version is available
set -e
# Get currently installed version
if command -v ffmpeg &> /dev/null; then
CURRENT_VERSION=$(ffmpeg -version 2>&1 | head -1 | grep -oP 'version \K[0-9.]+')
echo "Current installed version: $CURRENT_VERSION"
else
echo "FFmpeg is not installed. Run download-ffmpeg.sh first."
exit 1
fi
# Prompt for version branch
echo ""
echo "Available FFmpeg version branches:"
echo " 5 - FFmpeg 5.x (LTS, stable)"
echo " 6 - FFmpeg 6.x (stable)"
echo " 7 - FFmpeg 7.x (current stable)"
echo " 8 - FFmpeg 8.x (latest)"
read -p "Enter version branch to check (5/6/7/8) [7]: " VERSION_BRANCH
VERSION_BRANCH=${VERSION_BRANCH:-7}
# Validate input
case $VERSION_BRANCH in
5|6|7|8) ;;
*) echo "Invalid version. Using 7.x"; VERSION_BRANCH=7 ;;
esac
echo "Checking for FFmpeg ${VERSION_BRANCH}.x updates..."
# Get latest release tag from GitHub API
LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/FFmpeg/FFmpeg/tags?per_page=100" | \
grep -oP '"name": "n'"${VERSION_BRANCH}"'\.[0-9]+(\.[0-9]+)?"' | \
head -1 | \
grep -oP 'n[0-9.]+')
if [ -z "$LATEST_TAG" ]; then
echo "Error: Could not find a release for version ${VERSION_BRANCH}.x"
exit 1
fi
LATEST_VERSION="${LATEST_TAG#n}"
echo "Latest available version: $LATEST_VERSION"
# Compare versions
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "FFmpeg is already up to date."
exit 0
fi
echo ""
echo "Update available: $CURRENT_VERSION -> $LATEST_VERSION"
read -p "Proceed with update? (y/N): " CONFIRM
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Update cancelled."
exit 0
fi
# Download new version
cd ~/ffmpeg_sources
DOWNLOAD_URL="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/${LATEST_TAG}.tar.gz"
echo "Downloading FFmpeg $LATEST_VERSION..."
wget -O "ffmpeg-${LATEST_TAG}.tar.gz" "$DOWNLOAD_URL"
# Extract
echo "Extracting source..."
tar xzf "ffmpeg-${LATEST_TAG}.tar.gz"
# Update symlink
rm -f ffmpeg-current
ln -s "FFmpeg-${LATEST_VERSION}" ffmpeg-current
# Compile
echo "Compiling FFmpeg $LATEST_VERSION..."
cd ffmpeg-current
./configure \
--prefix="$HOME/ffmpeg_build" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="/usr/local/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libass \
--enable-libaom \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libsvtav1 \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265
make -j$(nproc)
sudo make install
sudo ldconfig
echo ""
echo "Update complete!"
ffmpeg -version | head -1
EOF
Make the update script executable:
chmod +x ~/ffmpeg_sources/update-ffmpeg.sh
To check for updates and recompile if available, run:
~/ffmpeg_sources/update-ffmpeg.sh
Run this script periodically (monthly or when you need specific new features) to keep your FFmpeg installation current. The script will tell you if you are already on the latest version for your chosen branch, so running it when no update exists is harmless.
Method 3: Deb-Multimedia Repository (Advanced Users Only)
This method fundamentally changes your system. Deb-Multimedia replaces core multimedia libraries with its own versions, affecting dozens of packages beyond FFmpeg. This can cause dependency conflicts, break other software, and complicate future system maintenance. Only proceed if you fully understand and accept these trade-offs.
Deb-Multimedia is a third-party repository maintained by Christian Marillat that provides FFmpeg builds with additional codecs and more frequent updates than Debian’s default packages. While functional, this repository takes an aggressive approach that replaces many system libraries.
Understand the Risks Before Proceeding
When you enable Deb-Multimedia and run apt upgrade, the repository will replace your system’s multimedia libraries with its own versions. This affects packages like libavcodec, libavformat, libswscale, and many others that other applications depend on.
Potential issues include:
- Dependency conflicts with software from Debian’s official repositories
- Delayed security updates if Deb-Multimedia lags behind Debian security patches
- Difficult-to-diagnose issues appearing weeks or months after installation
- Complications when upgrading to a new Debian release
- Applications built against Debian’s libraries may malfunction
For most users, Method 1 (Default APT) or Method 2 (Compile from Source) are safer choices. Only use Deb-Multimedia if you have a specific requirement that cannot be met by other methods and you are prepared to troubleshoot potential conflicts.
Back Up Your System First
Before enabling Deb-Multimedia, create a system backup or snapshot. If you encounter problems, you may need to restore your system to its previous state.
Import the Deb-Multimedia GPG Key
Deb-Multimedia requires bootstrapping because package authentication depends on their keyring package, but you cannot install the keyring package until the repository is configured. The safest approach is to download the GPG key directly from a trusted keyserver via HTTPS:
sudo apt install gpg curl -y
curl -fsSL 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x5C808C2B65558117' | sudo gpg --dearmor -o /usr/share/keyrings/deb-multimedia.gpg
This fetches the Deb-Multimedia signing key (maintained by Christian Marillat) directly over HTTPS and converts it to binary format for APT. This method avoids firewall issues with keyserver ports and works on minimal installations.
Add the Deb-Multimedia Repository
Create the repository configuration file using DEB822 format. This command detects your Debian release automatically:
cat <<EOF | sudo tee /etc/apt/sources.list.d/deb-multimedia.sources
Types: deb
URIs: https://www.deb-multimedia.org
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: main non-free
Signed-By: /usr/share/keyrings/deb-multimedia.gpg
EOF
The
$(. /etc/os-release && echo "$VERSION_CODENAME")command reads your Debian version directly from the system. This works on all Debian installations, including minimal and Docker containers wherelsb_releasemay not be available.
Install FFmpeg from Deb-Multimedia
The following command will upgrade system packages. Review the package list carefully before confirming. Many packages beyond FFmpeg will be replaced.
Update the package cache and install FFmpeg:
sudo apt update
sudo apt install ffmpeg
APT will show a list of packages to be installed and upgraded. Read this list carefully. If you see many packages being replaced (especially core libraries), this is Deb-Multimedia taking over system components.
Verify Installation
Check the installed version and confirm it comes from Deb-Multimedia:
ffmpeg -version
apt-cache policy ffmpeg
The apt-cache policy output should show the package source as deb-multimedia.org.
Basic FFmpeg Usage Examples
With FFmpeg installed, here are practical commands for common media tasks.
Convert Video to Different Format
Convert an MKV file to MP4 while preserving quality by copying streams without re-encoding:
ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4
The -c:v copy and -c:a copy flags copy the existing video and audio streams without re-encoding, making this operation fast and lossless. Stream copying only works when the codec is already compatible with the target container.
Convert with Re-encoding
When stream copying is not possible, re-encode the video. Convert AVI to MP4 with H.264 encoding:
ffmpeg -i input.avi -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4
The -preset medium balances encoding speed with compression efficiency. Use -preset fast for quicker encoding or -preset slow for better compression. The -crf 23 sets quality level where lower values produce higher quality (and larger files). Values between 18-28 work well for most use cases.
Extract Audio from Video
Pull the audio track from a video file and save it as MP3:
ffmpeg -i video.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3
The -vn flag discards the video stream, and -q:a 2 sets high-quality variable bitrate encoding (roughly 190 kbps). For constant bitrate, replace -q:a 2 with -b:a 320k.
Compress Video for Web
Reduce file size while maintaining reasonable quality for web delivery:
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset medium -c:a aac -b:a 96k -movflags +faststart output.mp4
The -movflags +faststart moves metadata to the beginning of the file, enabling playback to start before the full download completes.
Resize Video
Scale a video to a specific resolution:
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:a copy output.mp4
The -vf "scale=1280:720" resizes video to 720p. To maintain aspect ratio, use scale=1280:-1 (width fixed, height calculated) or scale=-1:720 (height fixed, width calculated).
Trim Video
Extract a portion of a video file:
ffmpeg -i input.mp4 -ss 00:01:30 -t 00:00:45 -c copy output.mp4
The -ss 00:01:30 sets the start time (1 minute 30 seconds), and -t 00:00:45 specifies the duration (45 seconds). Using -c copy avoids re-encoding for faster processing.
Batch Process Multiple Files
Convert all MKV files in a directory to MP4:
for file in *.mkv; do
ffmpeg -i "$file" -c:v libx264 -crf 23 -c:a aac "${file%.mkv}.mp4"
done
The "${file%.mkv}.mp4" syntax strips the .mkv extension and adds .mp4, preserving original filenames.
Troubleshooting Common Issues
Encoder Not Found Error
If FFmpeg fails with an unknown encoder error:
Unknown encoder 'libx264' Encoder libx264 not found
This means the required codec is not available in your FFmpeg build. Check which encoders are included:
ffmpeg -encoders | grep x264
If the encoder is missing, you need to either install the required development package and recompile (for source builds), or use an alternative encoder available in your build.
Missing Development Packages
If configuration fails during source compilation with missing library errors:
ERROR: libx264 not found
Install the corresponding development package:
sudo apt install libx264-dev
Common library packages: libx264-dev, libx265-dev, libvpx-dev, libmp3lame-dev, libopus-dev, libaom-dev.
Permission Denied Writing Output
If FFmpeg cannot write the output file:
output.mp4: Permission denied
Check the destination directory permissions:
ls -ld /path/to/output/directory
Change output location to your home directory or adjust permissions.
Source vs APT Version Conflicts
If both APT and source-compiled FFmpeg are installed, check which version is being used:
which ffmpeg
ffmpeg -version
The source-compiled version installs to /usr/local/bin/ffmpeg, while the APT version installs to /usr/bin/ffmpeg. The /usr/local/bin path typically takes precedence. To switch between versions, either remove one installation or use the full path when running commands.
Remove FFmpeg
Remove APT Version
To remove the APT-installed FFmpeg and its dependencies:
sudo apt remove ffmpeg
sudo apt autoremove
If you also installed the development packages:
sudo apt remove libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
Remove Source-Compiled Version
To remove the source-compiled FFmpeg installation:
sudo rm -f /usr/local/bin/{ffmpeg,ffprobe,ffplay}
Optionally, remove the build directories and source files:
rm -rf ~/ffmpeg_sources ~/ffmpeg_build
Update the shared library cache:
sudo ldconfig
Verify removal by checking that the ffmpeg command is no longer available:
which ffmpeg
Remove Deb-Multimedia Version and Repository
Removing Deb-Multimedia does not automatically restore your original Debian packages. System libraries that were replaced by Deb-Multimedia will remain until you manually reinstall them from Debian’s repositories.
Remove the repository and GPG key:
sudo rm -f /etc/apt/sources.list.d/deb-multimedia.sources
sudo rm -f /usr/share/keyrings/deb-multimedia.gpg
sudo apt update
Remove FFmpeg and its dependencies:
sudo apt remove ffmpeg
sudo apt autoremove
To restore core multimedia libraries from Debian’s official repositories, reinstall the libav packages for your Debian version:
# Find the correct package names for your Debian version
apt search libavcodec | head -5
# Reinstall from Debian repos (example for Debian 13)
sudo apt install --reinstall libavcodec61 libavformat61 libavutil59 libswscale8
Library version numbers change between Debian releases. Debian 13 (Trixie) uses libavcodec61, Debian 12 (Bookworm) uses libavcodec59, and Debian 11 (Bullseye) uses libavcodec58. Run
apt search libavcodecto find the correct package names for your system. A full system restore may require reinstalling affected packages individually.
Final Thoughts
You now have FFmpeg installed on Debian with the ability to convert videos, extract audio, compress files, and process media from the command line. The APT method provides a stable, security-maintained installation suitable for most users, while source compilation offers access to the latest features and custom codec configurations. To extend your multimedia workflow, pair FFmpeg with HandBrake for GUI-based video encoding, VLC for playback verification, or OBS Studio for streaming and recording.
Useful Links
Here are some useful links related to using FFmpeg:
- FFmpeg Official Website: Project homepage with download options and feature overview.
- FFmpeg Documentation: Comprehensive guides for all FFmpeg tools and options.
- H.264 Encoding Guide: Detailed guide to x264 encoding settings, presets, and quality tuning.
- H.265/HEVC Encoding Guide: x265 encoder options for smaller files at equivalent quality.
- AV1 Encoding Guide: Next-generation codec with libaom and SVT-AV1 encoder options.
- Hardware Acceleration Guide: Using VAAPI, NVENC, and Quick Sync for GPU-accelerated encoding.
- FFmpeg GitHub Repository: Source code, issue tracker, and release tags for source compilation.