Php-ffmpeg: Executable not found, proposed : avprobe, ffprobe

Created on 14 Jul 2015  Â·  47Comments  Â·  Source: PHP-FFMpeg/PHP-FFMpeg

similar to issue #45 and #66, except that I have avprobe and ffprobe and ffmpeg all in my system path.

this is on ubuntu 14.04

root@youknow-me:~# which ffmpeg
/usr/bin/ffmpeg

which ffprobe
/usr/bin/ffprobe

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

So I don't understand why it's not finding the binaries. It'd be nice if I could specify the binaries in parameters.yml or something similar, rather than passing it as an option when instantiating it in code, since that would require anyone else also working on the project to have those binaries in the same location, so that doesn't make sense.

suggestions?

bug

Most helpful comment

It can't be PATH problem, as following code works:

                $ffmpeg = FFMpeg::create([
                    'ffmpeg.binaries' => exec('which ffmpeg'),
                    'ffprobe.binaries' => exec('which ffprobe'),
                ]);

which searches in PATH and find executables.

All 47 comments

more info:

Alchemy\BinaryDriver\Configuration Object ( [data:Alchemy\BinaryDriver\Configuration:private] => Array ( [ffmpeg.binaries] => /usr/bin/ffmpeg [ffprobe.binaries] => /usr/bin/ffprobe ) )

for the life of me I cannot figure out why this vendor library will not load these executables.

try making the binary executable by using
sudo chmod +x /path/to/ffmpeg|ffprobe/binary
Solved the same problem I had.

ls -la ffmpeg
-rwxr-xr-x 1 root root 17033152 Jul 14 13:53 ffmpeg

ls -la avprobe
-rwxr-xr-x 1 root root 60560 Apr 10 16:22 avprobe

it's been that way, same error, i've just stopped using this bundle because of it. crap library.

i had the same problem, made no sense so i gave it the path to binaries explicitly like it says in https://github.com/PHP-FFMpeg/PHP-FFMpeg#ffmpeg and it worked

I am also experiencing the same problem. It does not make any sense.

Do you have open_basedir set? Please also mind, the PATH for webserver is most of the time not the same as the PATH of your user account.

It can't be PATH problem, as following code works:

                $ffmpeg = FFMpeg::create([
                    'ffmpeg.binaries' => exec('which ffmpeg'),
                    'ffprobe.binaries' => exec('which ffprobe'),
                ]);

which searches in PATH and find executables.

What does var_dump(getenv('PATH')) contain?

➜  ~  cat test.php
<?php
var_dump(getenv('PATH'));
var_dump(exec('which ffmpeg'));
➜  ~  php test.php
string(44) "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
string(21) "/usr/local/bin/ffmpeg"

I find this problem really strange, as code looks good and it works on some platforms.

Damn strange. Definitely no open basedir restriction set? var_dump(ini_get('open_basedir'))

Please also test those two, to be really sure:

  • var_dump(is_file(exec('which ffmpeg')))
  • var_dump(is_executable(exec('which ffmpeg')))

All good.

➜  ~ cat test.php
<?php
var_dump(getenv('PATH'));
var_dump(exec('which ffmpeg'));
var_dump(ini_get('open_basedir'));
var_dump(is_file(exec('which ffmpeg')));
var_dump(is_executable(exec('which ffmpeg')));
➜  ~ php test.php
string(44) "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
string(21) "/usr/local/bin/ffmpeg"
string(0) ""
bool(true)
bool(true)

Fuuuuuu, that's strange :(

Erm, you tested this all on console. Can you please test your test.php through the webserver?

I encountered that problem while running CLI script so it should not matter.There is output from web request:

string(88) "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
string(15) "/usr/local/bin/ffmpeg"
string(0) ""
bool(true)
bool(true)

Dr. Strange strikes again ^^

For the purpose of reproducing please add the output of composer show -i

And maybe copy your whole composer.json and composer.lock to hastebin please, so we can get exactly the same vendors :)

The same problem here. I tried everything, including setting the paths manually. Nothing works.

i have the same problem i try all the solution found in this question and others
the probleme is: Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffprobe failed to execute command '/usr/bin/ffprobe' '-help' '-loglevel' 'quiet''
i try running command manually, it's work !
another user have the same problem in this question #157

What we should do now i have the same problem and everything is alright with these commands :
var_dump(getenv('PATH'));
var_dump(exec('which ffmpeg'));
var_dump(ini_get('open_basedir'));
var_dump(is_file(exec('which ffmpeg')));
var_dump(is_executable(exec('which ffmpeg')));

string(60) "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
string(15) "/usr/bin/ffmpeg"
string(0) ""
bool(true)
bool(true)

Guys... Same error here on windows, executable runnable from system path... anyone found a solution?

For my Windows users...

I had this problem too. Spent two days using procmon to determine why PHP wasn't starting ffprobe.exe on a new Windows 2016 install.

Turns out if your IIS AppPool identity doesn't have at least modify writes on the C:\Windows\temp folder, you will get this misleading error.

You can get the App Pool identity/context of your site using (not to be confused with the user context provided from get_current_user(). ):

echo "Get ENV: ".getenv("APP_POOL_ID"); Or echo "Get SERVER: ".$_SERVER["APP_POOL_ID"];

From my analysis, this is because PHP-CGI.exe, CMD.exe & the ffmpeg exe's (ffmpeg.exe, ffprobe.exe, ffplay.exe) use flat files in the temp folder to exchange and parse information. When PHP-CGI.exe creates a temp file in this location all other processes can only read from the temp file, leaving it empty 0 bytes. Every page load, I had these empty temp files being written to C:\Windows\Temp and ffprobe.exe would never execute.

Hope this helps someone.

Same here, with PHP7 on Debian stretch.

var_dump(getenv('PATH'));
var_dump(exec('which ffprobe'));
var_dump(ini_get('open_basedir'));
var_dump(is_file(exec('which ffprobe')));
var_dump(is_executable(exec('which ffprobe')));

results in

bool(false)
string(16) "/usr/bin/ffprobe"
string(0) ""
bool(true)
bool(true)

I have also explicitly set the paths:

$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
    'ffprobe.binaries' => '/usr/bin/ffprobe'
  ));

Same problem here on Ubuntu 16.04.

Installed ffmpeg through:

sudo apt-get install ffmpeg

Both ffmpeg and ffprobe binaries are located in:

/usr/bin/ffmpeg
/usr/bin/ffprobe

My PATH:

/home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Getting the same error message. Makes no sense.

I'm sorry, but does this error still occur when you are explicit bound the wrapper to these files?

Same here

Probably, we should use a different service for locating software. The current one is not that maintained anymore, unfortunately. I'll explore in it once I'm not busy anymore.

Maybe, the sympliest is to provide a conf file like https://github.com/pascalbaljetmedia/laravel-ffmpeg

Well, we provide the conf file, in every case, you can set the binaries manually? I don't understand what you're trying to say?

It would be great that the constructor read a config file to set the binaries if not provided.

That's what we do at the moment. We're going even deeper, we ask the operation system.

Sorry but i don't find this config file. could you tell me where it is ?
I had always to provide binaries path at the create methode.

Well, with that configuration I mean the parameters from the create method, then I misunderstood you. I'm sorry.

I used the solution suggested by @gabrielkaputa, and it worked for me. The only two changes I made were:

  1. find out which ffmpeg and which ffprobe in Terminal first, and replaced the path in that array with my path;
  2. deleted $logger since I don't have that interface. It works without it for me.

The only question I have right now is that, in the scenario that I deploy this php file onto my web server, I should install ffmpeg on my server and set the path to where it is stored on my server, correct? Just want to double check. Sorry for this dummy question. I am new to php and backend.

The only question I have right now is that, in the scenario that I deploy this php file onto my web server, I should install ffmpeg on my server and set the path to where it is stored on my server, correct?

Yes, that's the right way to do that.

like this

$ffmpeg = FFMpeg\FFMpeg::create([
'ffmpeg.binaries' => '/usr/local/bin/avconv',
'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/avprobe',
'ffprobe.binaries' => '/usr/local/bin/ffprobe',
]);

you can use "which ffprobe",find the path

I have the same issue in my CentOS7 and php7. I have installed FFmpeg and FFProbe. Using which ffmpeg and which ffprobe in the terminal, I got the path:

[root@host ~]# which ffmpeg
/usr/bin/ffmpeg
[root@host ~]# which ffprobe
/usr/bin/ffprobe

I added the path to my FFMpeg config and its unable to find the FFProbe:

Executable not found, proposed : /usr/bin/ffprobe

My Php file produces this result:

<?php
  var_dump(getenv('PATH'));
  var_dump(exec('which ffmpeg'));
  var_dump(exec('which ffprobe'));
  var_dump(ini_get('open_basedir'));
  var_dump(is_file(exec('which ffmpeg')));
  var_dump(is_executable(exec('which ffmpeg')));
?>

string(28) "/bin:/usr/bin:/usr/local/bin"
string(0) ""
string(0) ""
string(0) ""
bool(false)
bool(false)

I have confirmed that the ffmpeg and ffprobe files inside /usr/bin has execute permission and I had also set it to 777. Totally stumped on this for 2 days. I installed the same in Mac and I had no issues. But my Centos server is giving this strange behaviour. I can't figure out why the php is not seeing the binary files when the path is correct.

Any suggestions please?

-- Neel

Could you check whether the user that is executing the php process has access to those files and open_basedir check is not activated @Mr-Anonymous ?

I'm facing same issue :/

currently i'm using


$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
    'ffprobe.binaries' => '/usr/bin/ffprobe'
  ));

using that code it works xD.

php runs as www-data (default user group)

I'm facing same issue ,on widows , it works by restart the webserver,,,,

Hi guys, had the same problem, check if SELinux is doing something, and also check the php setting open_basedir (php.net/manual/en/ini.core.php#ini.open-basedir)

cheers

Your solution fixed this issue for me! Works like a charm!

Hi guys, had the same problem, check if SELinux is doing something, and also check the php setting open_basedir (php.net/manual/en/ini.core.php#ini.open-basedir)

cheers

Hey. I had same problem that is now fixed. It differs from the solutions found above so I'm posting the fix in case it will help someone.
which ffmpeg and which ffprobe returned empty string, and getenv('PATH') returned /bin:/usr/bin.

putenv("PATH=".getenv('PATH').':/usr/local/bin');

Putting this code above \FFMpeg\FFMpeg::create did fix the problem.

Hope this will help.

For WAMP users on Windows 10 (please check FFmpeg directory on your drive, mine is C:/FFmpeg):

Change the line $ffmpeg = \FFMpeg\FFMpeg::create with:

$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries'  => 'C:/FFmpeg/bin/ffmpeg.exe',
    'ffprobe.binaries' => 'C:/FFmpeg/bin/ffprobe.exe'
));

Hope this help.

In my case, it was just a matter of passing the same configuration of FFMPEG::create() to FFProbe::create(), as follows:

$configuration = array(
    'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
    'ffprobe.binaries' => '/usr/bin/ffprobe'
  );

 $ffmpeg = FFMpeg\FFMpeg::create($configuration);

$ffprobe = FFMpeg\FFProbe::create($configuration);        

They both take the same parameters, but the project readme doesn't explicitly say they do.

The way FFMpeg get configuration by using get method of in this class Alchemy\BinaryDriver\Configuration in here :

$binaries = $configuration->get('ffmpeg.binaries', array('avconv', 'ffmpeg'));

this returns failed default array ['avconv', 'ffmpeg'] instead of ["/usr/bin/ffmpeg"]

so my temp solution to replace replace $binaries in FFMpeg\Driver\FFMpegDriver

$binaries = ["/usr/bin/ffmpeg"];

and $binaries in FFMpeg\Driver\FFProbeDriver

$binaries = ["/usr/bin/ffprobe"];

in my case I am using ffmpeg and located in /usr/bin/ffmpeg

What does var_dump(getenv('PATH')) contain?

You can set it:
putenv("PATH=/usr/bin");

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gemorroj picture Gemorroj  Â·  8Comments

mdolnik picture mdolnik  Â·  4Comments

pascalbaljet picture pascalbaljet  Â·  4Comments

h3242749 picture h3242749  Â·  5Comments

miraklo picture miraklo  Â·  6Comments