DebianDebian Based

How To Install FFmpeg on Debian 12

Install FFmpeg on Debian 12

In this tutorial, we will show you how to install FFmpeg on Debian 12. Video and multimedia processing has become an essential part of modern applications and platforms. FFmpeg, a powerful open-source software, enables users to manipulate, convert, and stream audio and video files with ease.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of FFmpeg on a Debian 12 (Bookworm).

Prerequisites

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for FFmpeg.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install FFmpeg on Debian 12 Bookworm

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt install apt-transport-https lsb-release ca-certificates build-essential git wget

This command will refresh the repository, allowing you to install the latest versions of software packages.

Step 2. Installing FFmpeg on Debian 12.

Now that your system is prepared, let’s move on to the installation process. There are two main methods: installing FFmpeg via the package manager or compiling it from the source.

  • Method 1: Installing FFmpeg via Package Manager.

FFmpeg is not available in the default Debian repositories. To access it, enable the non-free repository by editing the sources list file:

sudo nano /etc/apt/sources.list

Add the following line to the file:

deb http://deb.debian.org/debian bullseye main contrib non-free

Update the package list to include the newly added repository and Install FFmpeg by running the following command:

sudo apt update
sudo apt install ffmpeg
  • Method 2: Compiling FFmpeg from Source.

To compile FFmpeg from the source, you need to install additional build tools. Execute the following command:

sudo apt install build-essential nasm yasm libx264-dev libx265-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev

Next, create a directory for FFmpeg and navigate to it. Then, download the FFmpeg source code from the official website or via Git:

mkdir ~/ffmpeg
cd ~/ffmpeg
wget https://ffmpeg.org/releases/ffmpeg-x.x.x.tar.gz # Replace x.x.x with the desired version
tar xzf ffmpeg-x.x.x.tar.gz

After that, extracted the FFmpeg directory and configure the installation options:

cd ffmpeg-x.x.x
./configure --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame --enable-libopus

Once the configuration is complete, start the compilation process:

make -j$(nproc)
sudo make install

After installing FFmpeg, it’s essential to verify that the installation was successful. Perform the following checks:

ffmpeg -version

Step 3. Basic Usage of FFmpeg.

Now that FFmpeg is installed, let’s explore some basic usage scenarios to get you started on manipulating multimedia files:

  • Converting Video Formats:

FFmpeg allows you to convert videos to different formats effortlessly. Use the following command to convert a video file:

ffmpeg -i input.mp4 output.mkv
  • Extracting Audio from Video:

If you want to extract the audio track from a video file, use the following command:

ffmpeg -i input.mp4 -vn -acodec copy output.mp3
  • Trimming and Splitting Videos:

FFmpeg enables you to trim and split video files easily. Use the following commands as examples:

ffmpeg -i input.mp4 -ss 00:00:10 -t 00:00:20 -c:v copy -c:a copy output.mp4
ffmpeg -i input.mp4 -f segment -segment_time 10 -c copy output%d.mp4
  • Adding Watermarks to Videos:

You can overlay text or image watermarks on your videos using FFmpeg. Here are some examples:

ffmpeg -i input.mp4 -vf "drawtext=text='Your Watermark':fontsize=20:fontcolor=white:x=10:y=10" -c:v libx264 -crf 18 output.mp4
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:10" -c:v libx264 -crf 18 output.mp4

Step 4. Troubleshooting FFmpeg.

While installing and using FFmpeg, you may encounter some common issues. Here are a few troubleshooting tips to help you resolve them:

  1. Common Installation Issues:

    • Dependencies Not Found: Double-check that you have installed all the necessary dependencies mentioned earlier in the guide.
    • Compilation Errors: Verify that you followed the compilation steps correctly and that you have the required build tools.
  2. Common Usage Issues:

    • Unsupported Formats or Codecs: Ensure that FFmpeg supports the formats and codecs you are working with. Check the official FFmpeg documentation for a comprehensive list of supported formats and codecs.
    • Unexpected Output Quality or File Size: Experiment with different command options and settings to achieve the desired output quality or file size.

Congratulations! You have successfully installed FFmpeg. Thanks for using this tutorial for installing the latest version of FFmpeg on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official FFmpeg website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button