How to Install FFMPEG on CentOS 7

June 28, 2016 | By
| 1 Reply More

FFMPEG is a major multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play various audio and video files in different formats.  FFMPEG is a very fast video and audio converter that can also grab from a live audio/video source. It can also convert between arbitrary sample rates and re-size video on the fly with a high quality polyphase filter. It is supported by various library files like libavcodec, libavutil, libavformat, libavfilter, libavdevice, libswscale and libswresample.

libavcodec - an audio/video codec library
libavutil - utility library to aid portable multimedia programming
libavformat - library which provides framework for multiplexing and multiplexing video/audio and subtitle streams
libavfilter -  library which enhances a generic audio/video filtering
libavdevice -  library which  provides a framework grabbing from and rendering to many common multimedia input/output devices framework
libswscale - library enhancing highly optimized image scaling and colorspace and pixel format conversion operations
libswresample - library promoting audio resampling, rematrixing and sample format conversion operations

In short, it is a free software available with libraries and programs to handle multimedia data. It can also be used as a commandline tool in PHP and other programming languages for transcoding multimedia files.

Installation Steps for FFMPEG

We need to install a suitable repofile which includes this FFMPEG package which is the most important step of this installation.

I've tried various repos like RPMforge, EPEL and Webtatic repos in CentOS 7, but these repos lacked FFMPEG packages. Hence, I tried a new repo which is called Nux Dextop. Let's walk through the installation steps.

1. Enable Nux Dextop repo on CentOS 7

It is a third-party RPM repository that contains many popular multimedia related packages for CentOS releases. This repo work only if EPEL repo is enabled in the server. So you need to first make sure that you've enabled EPEL repo.

This is how we install EPEL repo on a CentOS 7 server.

#Install EPEL repo
yum -y install epel-release

After enabling epel repo, go ahead and install Nux Dextop repository.

root@server1 [~]# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
root@server1 [~]# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
Retrieving http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:nux-dextop-release-0-1.el7.nux ################################# [100%]
root@server1 [~]#

***IMPORTANT ***

Nux Dextop repository is an architecture independent RPM, so you can install the same RPM on both 32-bit and 64-bit.

We can now verify that the Nux Dextop repository is installed successfully.

nux1

2. Install FFMPEG and FFMPEG devel packages

By installing these packages, all the libraries will be installed in parallel.

root@server1 [~]# yum -y install ffmpeg ffmpeg-devel
===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
ffmpeg x86_64 2.6.5-1.el7.nux nux-dextop 1.5 M
ffmpeg-devel x86_64 2.6.5-1.el7.nux nux-dextop 286 k
Installing for dependencies:
SDL x86_64 1.2.15-14.el7 base 204 k
alsa-lib x86_64 1.0.28-2.el7 base 391 k
ffmpeg-libs x86_64 2.6.5-1.el7.nux nux-dextop 5.0 M
flac-libs x86_64 1.3.0-5.el7_1 base 169 k
fribidi x86_64 0.19.4-6.el7 base 63 k
gsm x86_64 1.0.13-11.el7 base 30 k
lame-libs x86_64 3.99.5-2.el7 nux-dextop 339 k
libXi x86_64 1.7.4-2.el7 base 40 k
libXtst x86_64 1.2.2-2.1.el7 base 20 k
libXv x86_64 1.0.10-2.el7 base 18 k
libass x86_64 0.13.1-1.el7 epel 90 k
libasyncns x86_64 0.8-7.el7 base 26 k
libavdevice x86_64 2.6.5-1.el7.nux nux-dextop 71 k
libcdio x86_64 0.92-1.el7 base 235 k
libcdio-paranoia x86_64 10.2+0.90-11.el7 base 70 k
libdc1394 x86_64 2.2.2-3.el7 epel 121 k
libogg x86_64 2:1.3.0-7.el7 base 24 k
libraw1394 x86_64 2.1.0-2.el7 base 63 k
libsndfile x86_64 1.0.25-10.el7 base 149 k
libtheora x86_64 1:1.1.1-8.el7 base 136 k
libusbx x86_64 1.0.15-4.el7 base 50 k
libv4l x86_64 0.9.5-4.el7 base 194 k
libva x86_64 1.2.1-3.el7 epel 68 k
libvdpau x86_64 1.1-2.el7 base 32 k
libvorbis x86_64 1:1.3.3-8.el7 base 204 k
mesa-filesystem x86_64 10.6.5-3.20150824.el7 base 23 k
openal-soft x86_64 1.16.0-2.el7 epel 282 k
openjpeg-libs x86_64 1.5.1-10.el7 base 85 k
opus x86_64 1.0.2-6.el7 base 630 k
orc x86_64 0.4.22-5.el7 base 165 k
pulseaudio-libs x86_64 6.0-7.el7 base 576 k
schroedinger x86_64 1.0.11-4.el7 epel 291 k
soxr x86_64 0.1.2-1.el7 epel 77 k
speex x86_64 1.2-0.19.rc1.el7 base 98 k
x264-libs x86_64 0.142-11.20141221git6a301b6.el7.nux nux-dextop 570 k
x265-libs x86_64 1.6-1.el7.nux nux-dextop 476 k
xvidcore x86_64 1.3.2-5.el7.nux nux-dextop 258 k

Transaction Summary
===============================================================================================================================================
Install 2 Packages (+37 Dependent packages)

 

3. Check and confirm FFMPEG version

You can use this command for checking the version of ffmpeg installed and to confirm the configuration set-up.

root@server1 [~]# ffmpeg
ffmpeg version 2.6.5 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Now we have completed with the installation of ffmpeg. You see how simple to install it when we move on the right track.

I will give you an example for converting a mp3 file to oog format using this module on CLI.

Download an mp3 file and execute the ffmpeg command to convert the mp3 file to ogg format.

root@server1 [/usr/local/src]# wget https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3
--2016-02-09 09:01:43-- https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3
Resolving ia802508.us.archive.org (ia802508.us.archive.org)... 207.241.228.198
Connecting to ia802508.us.archive.org (ia802508.us.archive.org)|207.241.228.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 198658 (194K)
Saving to: ‘mpthreetest.mp3’

100%[=====================================================================================================>] 1,98,658 999KB/s in 0.2s

2016-02-09 09:01:44 (999 KB/s) - ‘mpthreetest.mp3’ saved [198658/198658]

root@server1 [/usr/local/src]# ffmpeg -i mpthreetest.mp3 -c:a libvorbis -q:a 4 mpthreetest.ogg
ffmpeg version 2.6.5 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[mp3 @ 0x16e2e40] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'mpthreetest.mp3':
Metadata:
title : Test of MP3 File
artist : Me
album : Me
date : 2006
comment : test
track : 1
genre : Other
Duration: 00:00:12.42, start: 0.000000, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 128 kb/s
Output #0, ogg, to 'mpthreetest.ogg':
Metadata:
title : Test of MP3 File
artist : Me
album : Me
date : 2006
comment : test
track : 1
genre : Other
encoder : Lavf56.25.101
Stream #0:0: Audio: vorbis (libvorbis), 44100 Hz, mono, fltp
Metadata:
encoder : Lavc56.26.100 libvorbis
title : Test of MP3 File
artist : Me
album : Me
date : 2006
DESCRIPTION : test
TRACKNUMBER : 1
genre : Other
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
size= 105kB time=00:00:12.40 bitrate= 69.1kbits/s
video:0kB audio:100kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: 4.706274%

Now our MP3 test file is converted to Vorbis (ogg) audio compression format which is much better compared to mp3.

Similarly, we can encode, decode and convert any video, images or audio file formats using this commandline tool. We can even make use this module in PHP by proper coding. You can get more information on using this tool by referring to the manual page which you can get by running the command "man ffmpeg".

root@server1 [~]# man ffmpeg

transcodingprocess

I hope you enjoyed reading this documentation on FFMPEG. I would recommend your valuable suggestions and comments on this!

Have a Nice Day :)

Filed Under : LINUX HOWTO

Free Linux Ebook to Download

Comments (1)

Trackback URL | Comments RSS Feed

  1. Michal says:

    Thx so much. Nice HOW TO!

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.