Does simple ffmpeg package also work fine when we execute its command from PHP via exec? Or we have some different ffmpeg package for that purpose? Please help me solving it.
2 Answers
Yes simple ffmpeg
does work through PHP exec if you have necessary permissions.
Sample command
<?php
/*** convert video to flash ***/
exec("ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv");
?>

- 14,986
- 6
- 37
- 59

- 68,075
- 43
- 96
- 126
-
but i want to run it on browser. I know this php script runs on terminal but it is not working on browser. Does executing it on browser through PHP exec requires simple ffmpeg. – Ali faizan Sep 04 '13 at 11:54
-
@MarcellFülöp, Not neccessarily mate. Maybe his web's php.ini haven't got the exec enabled. – Shankar Narayana Damodaran Sep 04 '13 at 12:02
-
will this PHP exec script for ffmpeg command work on browser?? actually i want to run it through browser – Ali faizan Sep 04 '13 at 12:03
-
how to enable that in my php.ini file please help – Ali faizan Sep 04 '13 at 12:08
-
This works perfectly from browser if you have enough permissions to execute an `exec` command ! – Shankar Narayana Damodaran Sep 04 '13 at 12:08
-
@Alifaizan, Are you on shared hosting server ? – Shankar Narayana Damodaran Sep 04 '13 at 12:17
PHP's ffmpeg and the vanilla ffmpeg are independent packages. The php5-ffmpeg
package comes with the ffmpeg binary as a dynamic library. This means that you can install only php5-ffmeg
without installing the command line ffmpeg
package or vice versa or you can have both of them installed.
Therefore, the answer is yes, PHP will work with the command line ffmpeg
given it is installed.
I usually prefer using the command line ffmpeg in PHP via exec
. This allows for testing certain operations on the command line and once the result is as desired, the command can be used in PHP's exec
. On the other hand, in some situations, it may be preferable to use the php5-ffmpeg
package because it gives you the ability to use object oriented coding style when dealing with videos, conversion, etc.

- 14,986
- 6
- 37
- 59
-
my php exec script for ffmpeg is working fine but now i also want to run this php script for ffmpeg in browser. does that also works with simple ffmpeg package?? – Ali faizan Sep 04 '13 at 12:00
-
If it works in a command line, it should work in PHP `exec` as well. One hint is to use full path to ffmpeg (use the output of `which ffmpeg`). Another hint if it doesn't work in exec is to examine the output and the return value from `exec` by passing the 2nd and 3rd optional parameters to it. – marekful Sep 04 '13 at 12:02