简体   繁体   English

PHP-FFMPeg 将视频转换两次

[英]PHP-FFMPeg Converts Video Twice

I'm using FFMpeg's library for PHP (see https://github.com/PHP-FFMpeg/PHP-FFMpeg ).我正在使用 FFMpeg 的 PHP 库(参见https://github.com/PHP-FFMpeg/PHP-FFMpeg )。 After starting the convert process, the converted video's file size gradually increases (I constantly refresh the folder) and after converting finishes, the file size becomes 0 again and converting starts again.开始转换过程后,转换后的视频文件大小逐渐增加(我不断刷新文件夹),转换完成后,文件大小再次变为 0,再次开始转换。 So converting is done twice, I could not understand if it is normal or there is something wrong.所以转换做了两次,我不明白是正常还是有问题。

My converting code is:我的转换代码是:

require 'vendor/autoload.php';
$ffmpeg = FFMpeg\FFMpeg::create([
        'ffmpeg.binaries'  => 'C:/ffmpeg/ffmpeg.exe', 
        'ffprobe.binaries' => 'C:/ffmpeg/ffprobe.exe',
        'timeout'          => 0 
    ]);

$video = $ffmpeg->open($fileName);
$video
    ->filters()
    ->resize(new FFMpeg\Coordinate\Dimension(1920, 1080 ))
    ->synchronize();

$format = new FFMpeg\Format\Video\X264('libmp3lame');

try {
    $video->save($format, $outFileName);
} catch (Exception $e) {
    echo $e->getMessage();
}

This is because ffmpeg uses 2 pass encoding.这是因为 ffmpeg 使用 2 pass 编码。 https://superuser.com/questions/1362800/ffmpeg-2-pass-encoding https://superuser.com/questions/1362800/ffmpeg-2-pass-encoding

first it writes everything to a log and then from that log it makes the video首先它将所有内容写入日志,然后从该日志中制作视频

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM