Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I execute a ffmpeg command from terminal, I get the desired result:

ffmpeg  -i src.mp4 -ar 22050 -ab 32 -f flv -s 320x240 video.flv

Terminal's output

... video:3404kB audio:1038kB global headers:0kB muxing overhead 2.966904%

And video.flv is created correctly.

Then, if called via PHP exec:

exec("ffmpeg  -i src.mp4 -ar 22050 -ab 32 -f flv -s 320x240 video.flv", $o, $v);
var_dump($o);
var_dump($v);

the output is:

array(0) { } int(1)

And no file is created.

Any thoughts on how to approach this?

I can exec('whoami') with no problems.

I have used the ffmpeg full path as well: /usr/local/bin/ffmpeg

share|improve this question
    
Maybe exec() only captures stdout in output, not stderr. –  Oliver Salzburg Mar 24 '12 at 17:29
    
FFmpeg produces very weird output — you have to redirect both stdout and stderr to get everything AFAIK. –  slhck Mar 24 '12 at 17:32
    
I do not get the desired flv file created, so something is def. not working. Definitively the most urgent matter at this point ;) –  goliatone Mar 24 '12 at 17:34
add comment

2 Answers

add "2>&1" to the end of the command and it will work:

exec("ffmpeg  -i src.mp4 -ar 22050 -ab 32 -f flv -s 320x240 video.flv 2>&1", $o, $v);
share|improve this answer
add comment

right, the problem is that you use exec instead of shell_exec the point is that environement of exec don't know about any ffmpeg executable, but shell_exec does, becuase it uses env. of the bash/shell

Ths Solution use full path to ffmpeg executable, eg. /usr/bin/ffmpeg

share|improve this answer
    
No, the user said they tried /usr/local/bin/ffmpeg as well. –  slhck Jul 17 '12 at 15:02
1  
we had same issue half year ago, solution, described above, solved the problem, what about "/usr/local/bin/ffmpeg", maybe - bin folder is not correct !?.. –  Rodislav Jul 17 '12 at 15:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.