簡體   English   中英

mp4文件的PHP FFmpeg轉換問題

[英]PHP FFmpeg conversion issues for mp4 files

我想通過使用ffmpeg-phpmp4文件中獲取圖像。

我有

 $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()將其輸出為圖像。

例如,

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM