Scarface
Scarface

Reputation: 3923

Why does FFMPEG work in terminal but not in php with exec()?

I am trying to get FFMPEG to work in php. I just installed ffmpeg and x264 and ran the following command in my terminal:

$command = 'ffmpeg -i /home/gman/Desktop/cave.wmv -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 /home/gman/Desktop/newvideo.flv

It worked perfectly and created a new flv video from the inital video, just like I wanted.

Now when I try the same thing in php, nothing happens...

$safe_path = escapeshellarg("/home/gman/Desktop/newvideo.flv");
$command = 'ffmpeg -i /home/gman/Desktop/cave.wmv -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 ' . $safe_path;
exec($command);

Anyone have any ideas? Can I somehow see what exec is doing and see some sort of output? Would appreciate it.

Upvotes: 0

Views: 1757

Answers (2)

Scarface
Scarface

Reputation: 3923

http://blog.codyjung.com/2011/05/29/problems-with-lampp-and-exec/

My solution was to simply copy the ones from /usr/lib/i386-linux-gnu and overwrite the LAMPP ones. Could that cause problems later? Maybe, but I guess we’ll deal with that when it shows up.

Upvotes: 0

eagle12
eagle12

Reputation: 1668

Usually when you are calling ffmpeg in an exec you need to put in the absolute path to ffmpeg eg:

$safe_path = escapeshellarg("/home/gman/Desktop/newvideo.flv");
$command = '/usr/local/bin/ffmpeg -i /home/gman/Desktop/cave.wmv -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 ' . $safe_path;
exec($command);

Upvotes: 1

Related Questions