开发者

ffmpeg php exec not working

开发者 https://www.devze.com 2023-03-21 02:20 出处:网络
I have ffmpeg installed safe_mode is off when i do this: $movie = new ffmpeg_movie(\'Bear.wmv\'); I can use getDuration(), getFilename().... wthout any problems, so it\'s all seems to be working
  • I have ffmpeg installed
  • safe_mode is off
  • when i do this: $movie = new ffmpeg_movie('Bear.wmv'); I can use getDuration(), getFilename().... wthout any problems, so it's all seems to be working
  • exec is working fine, cos when i do: $output = exec('ls -lart'); I get a nice little result.

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 cou开发者_StackOverflow中文版ld 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!!??!


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];


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号