Execute FFMPEG Command in PHP

by CarcaBot on August 21, 2009 · 0 comments

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.

NOTE:
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.

<?   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

					
				

Leave a Comment

Previous post:

Next post: