Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sh: /usr/bin/ffmpeg: not found

I'm trying to execute ffmpeg from PHP using shell_exec or exec but it fails. Why can this be? The command /usr/bin/ffmpeg works from the terminal, so I tried

<?php
$cmd = "/usr/bin/ffmpeg";
exec($cmd." 2>&1", $out, $ret);
if ($ret){
    echo "There was a problem!\n";
    print_r($out);
}else{
    echo "Everything went better than expected!\n";
}
?>

and I keep on getting

There was a problem! Array ( [0] => sh: /usr/bin/ffmpeg: not found )

Any help would be greatly appreciated.

Permission on the executable are

-rwxr-xr-x  1 root   root      106552 Jun 12 09:53 ffmpeg

Running which /usr/local/bin/ffmpeg into $cmd returns an empty Array.

like image 436
Rio Avatar asked Nov 06 '12 03:11

Rio


1 Answers

The answer to your question might be simpler than expected. You're checking in both /usr/local/bin and /usr/bin. There are multiple solutions to this.

  1. You can run $ whereis ffmpeg and see what you get. Based on the results, change your $cmd variable. If whereis returns nothing, then your system doesn't know where it is. You can add it to your $PATH environment variable and try again.

  2. You can try to run $ find /usr -name "ffmpeg" or something similar. By ensuring that this program is installed, it will help you resolve this quicker.

  3. If there is some sort of restriction denying apache the ability to access/use ffmpeg, you can always store it in a bin folder within your document root. (something like /path/to/doc/root/bin/ffmpeg) I have done this before so I know it works.


If you find that ffmpeg is actually located in /usr/local/bin then you should just try changing your $cmd to this:

$cmd = '/usr/local/bin/ffmpeg';
like image 61
Yes Barry Avatar answered Nov 05 '22 02:11

Yes Barry