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.
In This blog we explains how to install FFmpeg on Debian 9
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 blog, 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:
Step 01: Start by updating the packages list:
$ sudo apt update
Step 02: Install the FFmpeg package by running the following command:
$ sudo apt install ffmpeg
Step 03: 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 -encoders
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.
In this section, we will show you some examples of how to use the ffmpeg tool.
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
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