Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP exec() Not Working With ffmpeg

Tags:

php

ffmpeg

exec

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.

like image 758
Dodinas Avatar asked Dec 23 '22 05:12

Dodinas


2 Answers

get the stderr will give the result

try

ffmpeg -i inputfile [more_params] 2>&1
like image 191
user432864 Avatar answered Dec 26 '22 12:12

user432864


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?

like image 41
geocar Avatar answered Dec 26 '22 14:12

geocar