[FFmpeg-user] Question about 2 pass encoding

Aditya Dandavate adityadandavate04 at gmail.com
Mon Apr 1 13:39:52 EEST 2024


In words of Gyan Dev Sir, a maintainer of FFMPEG,

"Two-pass is meant for when you have a fixed input and you wish to analyze
the file beforehand, so that the encode is optimized for the target bitrate
and other encoder parameters.

Your 1st command is discarding the capture. And so your 2nd command is
using the stats from pass 1 to apply to a new capture, which obviously
won't match.

Use

ffmpeg -y -rtbufsize 1500M -f gdigrab -framerate 30000/1001
-draw_mouse 0 -offset_x 224 -offset_y 232 -video_size 1280x720 -i
desktop -c:v libx264 -r 30000/1001 -an -tune zerolatency -preset
ultrafast -crf 0 Capture.mp4

and then

ffmpeg -y -i Capture.mp4 -pix_fmt yuv420p -c:v libx264 -pass 1 -an
-b:v 2600k -f mp4 NUL

ffmpeg -y -i Capture.mp4 -pix_fmt yuv420p -c:v libx264 -pass 2 -an
-b:v 2600k myVideo.mp4



Source :

 https://video.stackexchange.com/questions/21953/ffmpeg-error-2nd-pass-has-more-frames-than-1st-pass


So, I had a question :


Can I use `-c:a` copy for audio codec instead of `-an` for both passes ?


More information about the ffmpeg-user mailing list