mp4文件的PHP FFmpeg转换问题

时间:2013-04-19 21:04:36

标签: php ffmpeg

我希望使用mp4ffmpeg-php文件中获取图片。

我有

 $str_command= '/usr/bin/ffmpeg -i /test/ts.mp4 -r 1 -ss 00:00:10 -t 00:00:01 -s 300x300 -f image2 /test/images/';
 shell_exec($str_command);

但是,我收到一条错误消息

 Buffering several frames is not supported. Please consume all available frames before adding a new one.

我在网上花了好几个小时但却找不到答案。任何人都可以帮我这个吗?非常感谢!

1 个答案:

答案 0 :(得分:3)

你检查过PHP的ffmpeg库吗?我之前使用它,它抽象出所有复杂的命令行调用,就像你试图运行的那样。您可以使用$ movie-> getFrame($ n)来获取帧对象,使用$ frame-> toGDImage()将其输出为图像。

例如,

$movie = new ffmpeg('/path/to/movie.mp4');
$frame10 = $movie->getFrame(10);
$image = $frame10->toGDImage();

// Now display the image
header('Content-Type: image/jpeg');
imagejpeg($image);

// Or save it to a file
$saved = imagejpeg($image, '/path/to/new/file.jpg');

查看http://ffmpeg-php.sourceforge.net/doc/api/

上的文档
相关问题