2

I'm running Max OS 10.7, MAMP (PHP 5.3.6), with FFMPEG installed. I want to convert videos from one format to another. The following entered into Terminal works fine:

 ffmpeg -i /path/video.wmv /path/video.flv

The file video.wmv is converted to video.flv. Great! Now, this PHP line DOESN'T work:

 exec('ffmpeg -i /path/video.wmv /path/video.flv');

Why? I've spent many hours reading up on this and I still can't figure out what is wrong. I have read the other discussions on this topic and there is no clear answer. Any help would be greatly appreciated! (PHP safe_mode is off).

5
  • 2
    Check your error.log, make sure the binary is in the path, or add 2>&1 to receive some details on your wrongdoings. Commented Jan 22, 2012 at 19:34
  • This is propably a problem with permissions. The user which PHP or Apache is using doesn't have the permissions to access/write to the destinations. Commented Jan 22, 2012 at 19:35
  • File permissions are wide open. It seems like there are lots of people that have the same issue. I would expect that any command that I can enter into terminal can be used as an argument to exec(). Clearly, this isn't the case. Commented Jan 22, 2012 at 20:39
  • @JohnAnderson: The shell exec is running in might not be the same shell of your terminal, so you can't expect that out of the box. Commented Jan 27, 2012 at 15:48
  • possible duplicate of php exec ffmpeg how to get errors Commented Jan 27, 2012 at 15:50

1 Answer 1

7

I would double check that the path to ffmpeg is correct. Also, take a look at the output to see if has anything useful, like this:

exec("/usr/bin/ffmpeg -i $srcFile $destFile 2>&1", $output);
var_dump($output);
Sign up to request clarification or add additional context in comments.

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.