简体   繁体   中英

PHP-FFMPeg Converts Video Twice

I'm using FFMpeg's library for PHP (see 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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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