mp4文件的PHP FFmpeg转换问题

mp4文件的PHP FFmpeg转换问题,php,ffmpeg,Php,Ffmpeg,我想使用ffmpeg-php从mp4文件中获取图像 我有 $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

我想使用
ffmpeg-php
mp4
文件中获取图像

我有

 $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.

我在网上花了几个小时,但找不到答案。有人能帮我吗?非常感谢

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

比如说,,


查看位于

的文档,我确实读过,但没有想到这可能是解决方案。我相信这只能通过shell命令来完成。只需确保您也安装了GD库。
$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');