Installing FFmpeg on Linux
How to install FFmpeg and the PHP extension on Debian and CentOS.
FFmpeg is a collection of open-source libraries for recording, converting, and streaming audio and video in a wide range of formats. It includes libavcodec for encoding and decoding, and libavformat for media container multiplexing and demultiplexing.
Debian / Ubuntu
Install FFmpeg:
apt-get install ffmpeg
Install the PHP module:
apt-get install php5-ffmpeg
Restart Apache:
/etc/init.d/apache2 restart
Verify that the module is loaded:
php -i | grep ffmpeg
Expected output:
/etc/php5/cli/conf.d/20-ffmpeg.ini,
ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Apr 6 2012 16:24:10
ffmpeg-php gd support => enabled
ffmpeg libavcodec version => Lavc53.35.0
ffmpeg libavformat version => Lavf53.21.0
ffmpeg swscaler version => SwS2.1.0
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0
CentOS
Installing FFmpeg
Import the repository:
rpm -ivh https://www.mirrorservice.org/sites/dl.atrpms.net/el7-x86_64/atrpms/stable/atrpms-repo-7-7.el7.x86_64.rpm
Open the repository file:
vi /etc/yum.repos.d/atrpms.repo
Replace the baseurl line with the following:
#baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
baseurl=https://www.mirrorservice.org/sites/dl.atrpms.net/el$releasever-$basearch/atrpms/stable
Install FFmpeg:
yum install ffmpeg ffmpeg-compat ffmpeg-compat-devel ffmpeg-devel ffmpeg-libs
Installing the PHP extension
Install Git and clone the extension source:
yum install git
git clone https://github.com/tony2001/ffmpeg-php.git
Alternatively, download the ZIP archive from https://github.com/tony2001/ffmpeg-php and extract it manually.
Install the PHP development tools:
yum install php-devel gcc
Compile and install the extension:
cd ffmpeg-php
phpize
./configure
make && make install
Create the configuration file and add the module directive:
vim /etc/php.d/ffmpeg.ini
extension=ffmpeg.so
Save the file (:wq!) and verify that the module is loaded:
php -i | grep ffmpeg
Restart Apache:
systemctl restart httpd
Help
If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!