<p>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.</p>

<p>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.</p>

<p>Use</p>

<pre><code>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
</code></pre>

<p>and then</p>

<pre><code>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
</code></pre>

CC BY-SA 3.0
2017-07-20T19:30:39.587Z
Thanks I suspected I wasn't thinking about it correctly.  Bonus points for -framerate 30000/1001
Geordie
CC BY-SA 3.0
2017-07-20T10:51:59.127Z
2017-07-20T10:51:59.127Z
Gyan
<p>I'm recording video in windows 10 with gdigrab so want the capture as fast as possible in pass 1 and encode to a smaller file in pass 2.  No matter what I do I always get this error when executing pass 2:</p>

<blockquote>
  <p>[libx264 @ 000000000084ca60] 2nd pass has more frames than 1st pass
  (460) </p>
  
  <p>[libx264 @ 000000000084ca60] continuing anyway, at constant QP=4</p>
</blockquote>

<pre><code>Pass 1 command:
    ffmpeg -y -rtbufsize 1500M  -f gdigrab -framerate 29.97 -draw_mouse 0 -offset_x 224 -offset_y 232 -video_size 1280x720 -i desktop -pix_fmt yuv420p -c:v libx264 -r 29.97 -pass 1 -an -tune zerolatency -preset ultrafast -b:v 2600k -crf 0 -f mp4 NUL

Pass 2 command:
    ffmpeg -y -rtbufsize 1500M  -f gdigrab -framerate 29.97 -draw_mouse 0 -offset_x 224 -offset_y 232 -video_size 1280x720  -i desktop -pix_fmt yuv420p -c:v libx264 -r 29.97 -pass 2 -an -tune zerolatency -preset ultrafast -b:v 2600k -crf 22 C:/myVideo.mp4
</code></pre>

<p>I've tried setting -crf to 0 on the second pass but always get the same error.  Also the video that does get written by the second pass just has the first frame of the first pass. 
EDIT:  Also tried adding -passlogfile to no avail.</p>

<p>What am I doing wrong?</p>

<ffmpeg><libx264>
Ffmpeg error: 2nd pass has more frames than 1st pass
Geordie
# Ffmpeg error: 2nd pass has more frames than 1st pass

(Asked by: username_0 on 2017-07-20)

I'm recording video in windows 10 with gdigrab so want the capture as fast as possible in pass 1 and encode to a smaller file in pass 2.  No matter what I do I always get this error when executing pass 2:

[libx264 @ 000000000084ca60] 2nd pass has more frames than 1st pass
  (460) 
[libx264 @ 000000000084ca60] continuing anyway, at constant QP=4

Pass 1 command:
    ffmpeg -y -rtbufsize 1500M  -f gdigrab -framerate 29.97 -draw_mouse 0 -offset_x 224 -offset_y 232 -video_size 1280x720 -i desktop -pix_fmt yuv420p -c:v libx264 -r 29.97 -pass 1 -an -tune zerolatency -preset ultrafast -b:v 2600k -crf 0 -f mp4 NUL

Pass 2 command:
    ffmpeg -y -rtbufsize 1500M  -f gdigrab -framerate 29.97 -draw_mouse 0 -offset_x 224 -offset_y 232 -video_size 1280x720  -i desktop -pix_fmt yuv420p -c:v libx264 -r 29.97 -pass 2 -an -tune zerolatency -preset ultrafast -b:v 2600k -crf 22 C:/myVideo.mp4

I've tried setting -crf to 0 on the second pass but always get the same error.  Also the video that does get written by the second pass just has the first frame of the first pass. 
EDIT:  Also tried adding -passlogfile to no avail.
What am I doing wrong?

**Tags:** ffmpeg, libx264


---

## 1 answers

### Answer by username_1 on 2017-07-20. Score: 0 | Accepted answer

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

> **Comments:**
> **username_0**: Thanks I suspected I wasn't thinking about it correctly.  Bonus points for -framerate 30000/1001  

---

