How To Install FFmpeg on CentOS 7

Install FFmpeg on CentOS 7

In this tutorial, we will show you how to install FFmpeg on CentOS 7. For those of you who didn’t know, FFmpeg is a cross-platform solution for streaming audio and video as well as recording and conversion. There’s also a great PHP package called ffmpeg-php that allows for easy use of FFmpeg from inside PHP scripts. In this tutorial, I will show you the easy way to install ffmpeg and ffmpeg-php (php extension).

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 and FFmpeg-PHP extension on a CentOS 7 server.

Install FFmpeg on CentOS 7

Step 1. First, let’s start by ensuring your system is up-to-date.

yum clean all
yum install -y epel-release
yum -y update

Step 2. Installing the Nux repository.

After enabling Epel repo, go ahead and install the Nux Desktop repository:

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

Step 3. Installing FFmpeg and FFmpeg development packages on CentOS 7.

Install FFmpeg and ffmpeg-devel packages:

yum install ffmpeg ffmpeg-devel -y

To check for an installed FFmpeg version run:

ffmpeg -version

This should result in something very similar to the following output:

[[email protected] ~]# ffmpeg -version ffmpeg -version
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
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 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --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-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

If you want to learn more about FFmpeg, input:

ffmpeg -h

Step 4. Installing FFmpeg-PHP Extension on CentOS.

FFmpeg-PHP is a PHP extension that is used for accessing and retrieving information from video and audio files from within PHP scripts. Follow the steps below to install FFmpeg and ffmpeg-php on your Linux server:

yum install php-gd php-devel

Next, we download the latest ffmpeg-php release:

wget https://master.dl.sourceforge.net/project/ffmpeg-php/OldFiles/ffmpeg-php-0.6.2.tbz2
tar -xjf ffmpeg-php-0.6.2.tbz2
cd ffmpeg-php-0.6.2
phpize
./configure
make
make install

Now edit php.ini file:

nano /etc/php.ini

Add below lines at the end of php.ini:

[ffmpeg]
extension=ffmpeg.so

Restart Apache to make this change in effect:

service httpd restart

Verify the status of FFmpeg extension on a PHP info web page or from the command line as given below:

php -i | grep ffmpeg

Congratulations! You have successfully installed FFmpeg. Thanks for using this tutorial for installing FFmpeg in CentOS 7 system. For additional help or useful information, we recommend you to 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!