FFmpeg - PHP Error Code 127

2019-02-25 04:51发布

I am trying to execute FFmpeg from php. I have installed FFmpeg-php, and the extension is in the modules directory and it shows up in phpinfo. FFmpeg is working fine as I can run the command in a terminal and it outputs the video. However, when I try and run the command from php using the following script:

exec(ffmpeg -i input.avi output.avi);

But I get a '127' error code.

The extension is loaded in using:

$extension      = "ffmpeg";
$extension_soname   = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;

// Locate Extension
define('FFMPEG_LIBRARY', '/usr/local/bin/ffmpeg');

// Load Extension
if (!extension_loaded($extension))
    echo dl($extension_soname) or die("Can't load extension $extension_fullname\n");

I have also tried defining the aboslute extension location in the command:

exec(/usr/local/bin/ffmpeg-i input.avi output.avi);

Again, this works in the terminal but still returns the same erro code using the php exec().

Has anyone got any ideas?

Thank you.

标签: php ffmpeg
2条回答
干净又极端
2楼-- · 2019-02-25 05:17

I just had the same issue (ffmpeg not running through exec/system)

I sorted it by using /usr/bin/ffmpeg instead of just ffmpeg

查看更多
forever°为你锁心
3楼-- · 2019-02-25 05:19

If you got the module loaded, use the php-ffmpeg api instead of exec. Run exec only if the module wasn't loaded or else you've loaded the module for nothing (meaning you're not using the module at all).

The error you recive is from ffmpeg binary (not the extension, though you're not using the extension at all) , so search for ffmpeg status 127 error to resolve the problem related to ffmpeg.

查看更多
登录 后发表回答