Dodinas Dodinas - 4 months ago 70
PHP Question

PHP exec() Not Working With ffmpeg

I'm attempting to run the following command in PHP (on Ubuntu):

<?php
if (exec("/home/johnboy/ffmpeg/ffmpeg -i test1.mp4 -acodec aac -ab 128kb -vcodec mpeg4 -b 1220kb -mbd 1 -s 320x180 final_video.mov"))
{ echo "Success"; }
else { echo "No good"; }


And I always get "No good" echoed back, and no file created.

Interestingly, if I run the same exact command in Shell, it works, no problems.

Also, when I run the same code above, but subsitute "whoami" instead of the ffmpeg stuff, it works. (It echoes back "Success")

Any ideas on why this wouldn't be working? Thanks.

Answer

Can the apache/web user reach /home/johnboy/ffmpeg/ffmpeg? That is, perhaps /home/johnboy is 0700 instead of 0755?

Perhaps there are resource limits affecting loading of such a large program and all its libraries?

If you run the script to the php cli sapi, does it behave correctly? Even when running as the apache user?

What does strace -ff show when the apache web user runs the php script through the php cli?


Another solution you can try is to change your directory ownership. On Ubuntu you might need to

chown -R www-data:root /var/www

^ Or whatever your group is. www-data is the important part there.

Comments