Applicable to:
- Plesk for Linux
Question
How to install the ffmpeg-php extension in Plesk for CentOS 7?
Answer
Note: For a single website, the 'composer' can be used instead. See the command below for the installation and the following link for usage examples: https://github.com/PHP-FFMpeg/PHP-FFMpeg # /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar install php-ffmpeg/php-ffmpeg
If you would like to see ffmpeg-php pre-installed in PHP provided by Plesk, please vote for this feature on Plesk UserVoice.
Below are the steps to install ffmpeg-php extension for PHP 5.6 provided by Plesk on CentOS 7:
-
Connect to a Plesk server via SSH.
-
Install the EPEL repository:
# yum install epel*
-
Enable RPM Fusion:
# yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
# yum localinstall --nogpgcheck https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm -
Install FFmpeg and packages necessary for its installation:
# yum install ffmpeg ffmpeg-devel mplayer mencoder flvtool2 libogg libvorbis lame
# yum install make plesk-php56-devel gcc glibc-devel zlib-devel -
Download ffmpeg-php:
# mkdir /root/ffmpeg_dir
# cd /root/ffmpeg_dir && git clone https://github.com/nilsringersma/ffmpeg-php
# cd ffmpeg-php
# /opt/plesk/php/5.6/bin/phpize -
Modify the
ffmpeg_frame.c
file:6.1. Open the file in any text editor. In this example, we are using the vi editor:
# vi /root/ffmpeg_dir/ffmpeg-php/ffmpeg_frame.c
6.2. Find the lines:
CONFIG_TEXT: #ifdef HAVE_CONFIG_H
#include "config.h"
#endifand right after them add:
CONFIG_TEXT: #ifndef PIX_FMT_RGB32
#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32
#endif6.3. Save the changes and close the file.
-
Edit the file
php_ffmpeg.h
using the command:# sed -i 's/define av_frame_alloc avcodec_alloc_frame/define avcodec_alloc_frame av_frame_alloc/g' /root/ffmpeg_dir/ffmpeg-php/php_ffmpeg.h
-
Configure & make:
# ./configure --with-php-config=/opt/plesk/php/5.6/bin/php-config --enable-skip-gd-check
# make clean && make && make install -
Enable the extension and update PHP settings in Plesk:
# echo "extension=ffmpeg.so" > /opt/plesk/php/5.6/etc/php.d/ffmpeg.ini
# plesk bin php_handler --rereadThe extension will also appear in Plesk at Tools & Settings > PHP Settings > PHP 5.6 (No matter CGI, FastCGI or FPM application).
Comments
4 comments
Hello Alexandr, it’s possible to install it for php 7? cause all my scripts are working now with php 7.
Regards
Carsten
@Carsten Sachse
Unfortunately, it cannot be compiled due to conflicts with Zend, which is included in PHP 7.0 shipped with Plesk:
You may try to add custom PHP version and to install FFmpeg module for it.
ffmpeg is installed but script cant find it here /usr/bin/ffmpeg
@Sohail Khan
Hi!
Please check whether 'ffmpeg_path' is specified in the script and that it is pointing to /usr/bin/ffmpeg.
Check that ffmpeg is in place:
# whereis ffmpeg
ffmpeg: /usr/bin/ffmpeg /usr/include/ffmpeg /usr/share/ffmpeg /usr/share/man/man1/ffmpeg.1.gz
And check that permissions on /usr/bin/ffmpeg are 755 root:root.
Please sign in to leave a comment.