How To Install FFmpeg on Ubuntu 18.04 / Ubuntu 16.04 & Linux Mint 19
FFmpeg is an open source software (also a command line tool) for transcoding multimedia files. It is a suite, contains a set of shared libraries such as libswresample, libavcodec, libavformat, and libavutil and programs for handling video, audio, and other multimedia files and streams.
With FFmpeg, you can convert various video and audio formats. Also, it can capture and encode in real-time from hardware such as the TV capture card.
Install FFmpeg on Ubuntu / Linux Mint
This post explains to you how to install FFmpeg on Ubuntu 18.04 / Ubuntu 16.04 & Linux Mint 19 and use it.
Install FFmpeg v4.x
The version included in the Ubuntu repositories always lags behind the release of FFmpeg.org. If you want to install the latest version of FFmpeg (v4.x), you will need to use the jonathonf/ffmpeg-4
PPA.
Add the PPA to your system.
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
Fix: add-apt-repository command not found.
Update the repository index.
sudo apt update
Once you have added PPA to your system, install the FFmpeg package using the below command
sudo apt install -y ffmpeg
Install FFmpeg v3.x / v2.x
The base Ubuntu/Linux Mint repository has FFmpeg packages, and that can be installed using the apt package management tool.
Update the repository index.
sudo apt update
Install the FFmpeg by running the following command.
sudo apt install -y ffmpeg
Verify FFmpeg Installation
Verify the installation by running the ffmpeg -version
command which will print the FFmpeg version.
ffmpeg -version
Output v4.x:
ffmpeg version 4.1.1-0york1~18.04 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04) configuration: --prefix=/usr --extra-version='0york1~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100
Additionally, you can list all available FFmpeg’s encoders and decoders using the below command.
ffmpeg -encoders ffmpeg -decoders
FFmpeg is now installed on your system, and you can start using it.
How To Use FFmpeg
Here, we will see a few examples of how to use the ffmpeg command line tool.
Basic Conversion
To convert an audio or video files with FFmpeg, you do not need to specify the input and output formats. FFmpeg will auto-detect input format and converts it to other format based on the file extension of an output file.
Convert a video from mp4 to WebM.
ffmpeg -i video.mp4 video.webm
Advanced Conversion
To specify the codecs, you can use the -c option. You can put the name of any supported decoder/encoder or a special value copy which simply copies the input stream along with -c.
This will copy the audio (-c:a copy) from input.webm and convert the video to a VP9 codec (-c:v vp9) with a bit rate of 1M/s (-b:v), all bundled up in a Matroska container (output.mkv).
ffmpeg -i input.webm -c:a copy -c:v vp9 -b:v 1M output.mkv
Conclusion
You have successfully installed FFmpeg on Ubuntu 18.04 / Ubuntu 16.04 & Linux Mint 19 and learned how to do a simple conversion. You can visit the FFmpeg website to learn more about how to use FFmpeg to convert your video and audio files.