matt
matt

Reputation: 2352

ffmpeg php exec not working

but when I do this:

exec('ffmpeg -i Bear.wmv outputfile.flv')

nothing happens

if I add: $command_output, $result the only result i guess is: array { }

I have tried everything I could think of:

exec('ffmpeg -i Bear.wmv outputfile.flv')

exec('ffmpeg.so -i Bear.wmv outputfile.flv')

exec('/usr/lib/php5/20090626/ffmpeg -i Bear.wmv outputfile.flv')

I've tried all sizes and folders and codecs but still don't get anything back

All i wanna do is convert that video, Bear.wmv to an flv file.

I'm very close to crying like a baby and/or jumping out of the window (im only on the first floor but still lol) so Please help!!??!

Upvotes: 0

Views: 1734

Answers (2)

Piotr Müller
Piotr Müller

Reputation: 5558

FFMPEG is a application wich don't output to STDIO but STDERR, so you can redirect it to standard output:

$cmd = $FFMPEGDIR . " -i somefile.avi 2>&1"; // SEE 2>&1 !!

Extracting size:

 exec( $cmd , $info );

      echo "<pre>".print_r($info,true)."</pre>";
      $resolution = preg_match( '@[ ,\t]([0-9]{3,4}x[0-9]{3,4})[ ,\t]@si' , implode( " " , $info ) , $durmatches );

      $rtab = explode( "x" , $durmatches[1] );

      $videowidth = $rtab[0];
      $videoheight = $rtab[1];

Upvotes: 1

Brian
Brian

Reputation: 8626

Recently set ffmpeg up for audio stuff... it's a bit of a black art, ffmpeg is notorious for not playing nice (or consistently) - what works (worked) for me might not work for you!

try using: shell_exec()

or:

$command="{$FFMPEG_BINARY} ... rest of your options";
$process=proc_open($command, $descriptors, $pipes);
if (!$process)
{
    // failed to exec...
}
else
{
    // command ran...
}

my ffmpeg was in... "/usr/bin/ffmpeg" just check you've got right path too.

Upvotes: 0

Related Questions