1

I want to get the images out of a mp4 file by using ffmpeg-php.

I have

 $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);

However, I got an error message saying

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

I have spent hours on web but couldn't find the answer for this. Can anyone help me about this? Thanks so much!

4

1 回答 1

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/上的文档

于 2013-04-19T22:24:11.213 回答