4

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, thanks for the reply. How do I use the php-ffmpeg api to convert the file? I currently use it get variables such as size and bit rate etc. Also, I cant find any info on the ffmpeg 127 error. Is the 127 error code from the exec command as it cannot find the path?
for the status code 127 check google results google.ro/… , looking at the api it looks like you don't have any methods to convert a movie tough it seams strange not to have that option i'll look into it , run some tests and get back to you with the results .
Thank you!. It was caused by a couple of mis-named libraries from many reinstalls of ffmpeg. My exec() code was node reporting the error correctly. Thanks again!
2

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.