Applicable to:
- Plesk for Linux
Question
How to install the ffmpeg-php extension in Plesk?
Answer
Note: Due to the issue discussed here, ffmpeg-php cannot be installed for PHP 7.x provided by Plesk due to conflicts with Zend.
The following error message will appear during installation:
Error: too many arguments to function 'zend_hash_find'
In order to install ffmpeg-php for Plesk PHP 7.x, a custom PHP version should be installed and then ffmpeg-php be installed for it.
If you would like to see ffmpeg-php pre-installed in PHP provided by Plesk, please vote for this feature on Plesk UserVoice.
Follow the next steps to install ffmpeg-php extension for PHP 5.6 provided by Plesk on Plesk Obsidian CentOS 7, Plesk Obsidian Ubuntu 16.04 or Plesk Onyx CentOS 7:
Warning: all actions below are performed at your own risk.
Click on a section to expand
-
Log in to Plesk
-
Install Composer extension from Plesk extension catalog in Extensions
-
Go to Domains > example.com > File Manager and, in its document root create a file named
composer.json
with the content below:CONFIG_TEXT: {
"require": {
"php-ffmpeg/php-ffmpeg": "^0.14.0"
}
}Note: The domain example.com is the domain where ffmpeg-php is going to be used
-
Go to Domains > example.com > PHP Settings and select 5.6.40
-
Go to Domains > example.com > PHP Composer click Install under Package Dependencies.
Note: the
ffmpeg-php
is installed in/var/www/vhosts/example.com/httpdocs/vendor/php-ffmpeg
directory. -
If Scan button appears in the popup, press it.
-
To start using php-ffmpeg add the below to the website code in a PHP page to load the library:
CONFIG_TEXT: require 'vendor/autoload.php';
-
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 ffmpeg extension will also appear in Plesk at Tools & Settings > PHP Settings > PHP 5.6 (No matter CGI, FastCGI or FPM application).
Comments
18 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.
# 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
any guide on how to do this on specific subscription?
Hi Alex,
I follow this : /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar install php-ffmpeg/php-ffmpeg
But get bellow error:
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Invalid argument php-ffmpeg/php-ffmpeg. Use "composer require php-ffmpeg/php-ffmpeg" instead to add packages to your composer.json.
Please help.
Hello @Sharul Hafiz,
PHP extension cannot be installed for a single website, only for the whole PHP
However, as soon as you installed it to some specific PHP version, select this PHP for the domain:
How to change PHP version for a domain in Plesk?
I also removed incorrect information from the article. Thank you for pointing that out!
Hello @VAV
The "composer install" does not require specifying packages (the same info can be found here)
Thus, the correct command will be the next:
However, if you would like to add the mentioned packages to the "composer.json" file, use the next command (the same info can be found here):
Additional information about Composer CLI can be found here:
Composer Documentation | CLI
We install successful with 7.3 php version and work fine. Thanks for Nikita.
We have this error in final: https://www.codepile.net/pile/YxRyXjMn
Hi @Ion Iacob,
One point here: you successfully installed the ffmpeg-php extension for PHP 7.3
OR
The following error appears:
in an attempt to run this command:
?
The ffmpeg-php works, but after executing this # make clean && make && make install it gave the errors that I shared.
The extension is not displayed in Plesk at Tools & Settings> PHP Settings> PHP 7.3
Hi @Ion Iacob,
Reproduced the same errors on my test environment
It happens when steps 6.1, 6.2 and 6.3 were skipped
Please edit the ffmpeg_frame.c file as it suggested in these steps and follow steps 7, 8 and 9 further
If the issue still occurs, please repeat all steps from the beginning one more time in order to make sure that nothing was missed
Hi is there still no solution to this?
I have an application that required ffmpeg and php7.2 or later.
@Mark Tierney
You may install a custom 7.2 PHP version and install ffmpeg-php for it.
Thanks, so far everything seems to be working fine on the normal php 7.2 version.
I followed these instructions:
Then installed the ffmpeg php packages via composer.
I had to add the paths for ffmpeg and ffprobe to the open_basedir path in my php settings and all works fine thanks.
It seems that the application I am using it cannot receive the ffmpeg path when it already has extenson in php5.6. Although it does recognize, it will error is not recognized.
# whereis ffmpeg
ffmpeg: /usr/bin/ffmpeg /usr/include/ffmpeg /usr/share/ffmpeg /usr/share/man/man1/ffmpeg.1.gz
i use /usr/bin/ffmpeg.I had to switch from cpanel to plesk because it responds too slowly, but ffmpeg seems to be very difficult to install.
Hello,
As mentioned in the article the ffmpeg is not supported currently and all steps are given as a reference. If there some issues with that I suggest you to review the available sources on the possible cause.
In addition you may get in touch with our Professional Service team and discuss possibility of extension installation on paid basis:
https://www.plesk.com/professional-services/
Also I encourage you to share vote for implementing this functionality on our Uservoice portal:
https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/13114461
You are more than welcome to share your opinion in comment section.
Hello,
Please confirm if this is an issue with PHP 8?
If PHP 8, is OK, what are steps to install?
Thanks!
Please sign in to leave a comment.