Execute FFMPEG Command from PHP Applications
It has been a nightmare for me searching for executing FFMPEG command from PHP. But finally i got the solution for executing ffmpeg from php script. This article will guide you on how to convert videos and audios using FFMPEG from within the PHP scripts.
I have tested this on Red Hat Enterprise(RHEL). Not sure about other Linux OS like Ubuntu etc. But i would say if it works then its rocking to execute FFMPEG inside the php scripts.
1 2 3 4 5
< ? define('FFMPEG_LIBRARY', '/usr/local/bin/ffmpeg '); $exec_string = FFMPEG_LIBRARY.' -i inputfile.mpg outputfile.flv'; exxc($exec_string); //where exxc is the command used to execute shell command in php ?>
PHP Code Explanation
- Defined an variable called FFMPEG_LIBRARY that holds the path to FFMPEG Libraries
- Finally i am calling exec() function that executes the FFMPEG command