How to Install and Use FFmpeg on Debian 9

Updated on

3 min read

Install FFmpeg on Debian 9

FFmpeg is a free and open-source command-line tool for transcoding multimedia files. It contains a set of shared audio and video libraries such as libavcodec, libavformat, and libavutil. With FFmpeg, you can convert between various video and audio formats, set sample rates, and resize videos.

This tutorial explains how to install FFmpeg on Debian 9.

Prerequisites

You’ll need to be logged in as a user with sudo privileges to be able to install packages on your Debian system.

Installing FFmpeg on Debian

The official Debian repositories contain FFmpeg packages that can be installed with the apt package manager. At the time of writing this article, the current version of FFmpeg available in the Debian 9 repositories is 3.2.12.

The following steps describe how to install FFmpeg on Debian 9:

  1. Start by updating the packages list:

    sudo apt update
  2. Install the FFmpeg package by running the following command:

    sudo apt install ffmpeg
  3. Validate the installation by running the ffmpeg -version command which will print the FFmpeg version:

    ffmpeg -version

    The output should look something like the following:

    ffmpeg version 3.2.12-1~deb9u1 Copyright (c) 2000-2018 the FFmpeg developers
    built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516

    To print all available FFmpeg’s encoders and decoders you can use:

    ffmpeg -encodersffmpeg -decoders

That’s it. FFmpeg is now installed on your system, and you can start using it.

The version included in the Debian repositories always lags behind the latest version of FFmpeg. If you want to install the latest version of FFmpeg you’ll need to build the FFmpeg tools from source .

FFmpeg Examples

In this section, we will show you some examples of how to use the ffmpeg tool.

Basic conversion

When converting audio and video files with ffmpeg you do not have to specify the input and output formats. The input file format is auto detected and the output format is guessed from the specified file extension.

  • Convert a video file from mov to mp4:

    ffmpeg -i input.mov output.mp4
  • Convert an audio file from mp3 to flac:

    ffmpeg -i input.mp3 output.flac

Specifying codecs

To specify the codecs use the -c option. The codec can be the name of any supported decoder/encoder or a special value copy that simply copies the input stream.

  • Convert a video file from mp4 to webm using the libvpx video codec and libvorbis audio codec:

    ffmpeg -i input.mp4 -c:v libvpx -c:a libvorbis output.webm
  • Convert an audio file from mp3 to ogg encoded with the libopus codec.

    ffmpeg -i input.mp3 -c:a libopus output.ogg

Conclusion

You have learned how to install FFmpeg on Debian 9. You can now visit the official FFmpeg Documentation page and learn how to use FFmpeg to convert and your video and audio files.

If you hit a problem or have feedback, leave a comment below.