Body: <p>Recently, videos produced by capturing a window on my system using FFmpeg have become choppy/jerky, as if frames have been dropped or duplicated. FFmpeg will sometimes report that a number of frames were dropped when recording began, but not throughout the video. Videos I had recorded a few months ago did not suffer from this. Encoding speed reports to be between 1.0x &amp; 0.996x.</p>
  
  <p>I suspected that the problem might have to do with system performance related to the hard drive. So I cleaned up junk files on my system &amp; defragmented the drive. But the resulting video output did not change.</p>
  
  <p>Reading through <a href="https://ffmpeg.org/pipermail/ffmpeg-user/2017-March/035518.html" rel="nofollow noreferrer">this thread</a>, one user recomends recording at 30 fps instead of 60. But I had no problem recording at 60 before.</p>
  
  <p>The dimensions of the window I am recording are 512x448. I record the audio &amp; video in separate FFmpeg processes (this prevents audio drift).</p>
  
  <p>The following is an example portion of a script I use for recording:</p>
  
  <pre><code>ffmpeg -hide_banner -rtbufsize 500M -thread_queue_size 512 -f dshow -ac 1 -i audio="&lt;audio_device&gt;" -c:a pcm_s16le audio-tmp.wav &amp; APID=$!
  
  ffmpeg -hide_banner -rtbufsize 1500M -thread_queue_size 512 -f gdigrab -framerate 60 -i title="&lt;window_name&gt;" -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" video-tmp.mkv
  </code></pre>
  
  <p>The entire script can be found <a href="https://gist.github.com/AntumDeluge/75f63661c75cdc77c3497a3515b1b2fe/d3e7302128bd70c7df0913dde711c892aa4ec289" rel="nofollow noreferrer">here</a>.</p>
  
  <p>System specs:</p>
  
  <ul>
  <li><a href="https://support.hp.com/us-en/document/c05381021" rel="nofollow noreferrer">HP Pavilion 24-b217c</a></li>
  <li><strong>CPU:</strong> Intel Core i5-7400T
  
  <ul>
  <li>2.4GHz</li>
  <li>4 cores</li>
  </ul></li>
  <li><strong>RAM:</strong> 12GB</li>
  <li><strong>GPU (hybrid):</strong>
  
  <ul>
  <li>NVIDIA GeForce 930MX</li>
  <li>2GB dedicated RAM</li>
  <li>Intel HD Graphics 630</li>
  </ul></li>
  </ul>
  
  <p><strong>Edit:</strong> Here is the video output from the terminal:</p>
  
  <pre><code>Input #0, gdigrab, from 'title=Mega Man Unlimited':
    Duration: N/A, start: 1550055137.876177, bitrate: 440427 kb/s
      Stream #0:0: Video: bmp, bgra, 512x448, 440427 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (bmp (native) -&gt; h264 (libx264))
  Press [q] to stop, [?] for help
  [libx264 @ 000001d2881a15c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
  [libx264 @ 000001d2881a15c0] profile High 4:4:4 Intra, level 3.1, 4:4:4, 8-bit
  [libx264 @ 000001d2881a15c0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=1 keyint_min=1 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
  Output #0, matroska, to 'C:/users/antum/Videos/Captures/output-2019-02-13_10.52.17.456113800-video.mkv':
    Metadata:
      encoder         : Lavf58.26.101
      Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 512x448, q=-1--1, 60 fps, 1k tbn, 60 tbc
      Metadata:
        encoder         : Lavc58.47.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
  frame=14587 fps= 60 q=-1.0 Lsize= 1625062kB time=00:04:03.13 bitrate=54753.8kbits/s speed=   1x
  video:1624328kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.045149%
  [libx264 @ 000001d2881a15c0] frame I:14587 Avg QP: 0.00  size:114027
  [libx264 @ 000001d2881a15c0] mb I  I16..4: 100.0%  0.0%  0.0%
  [libx264 @ 000001d2881a15c0] coded y,u,v intra: 46.0% 44.6% 44.6%
  [libx264 @ 000001d2881a15c0] i16 v,h,dc,p: 77% 23%  0%  0%
  [libx264 @ 000001d2881a15c0] kb/s:54725.45
  </code></pre>
  
  <p>And here is some of the audio output (output to file):</p>
  
  <pre><code>Guessed Channel Layout for Input Stream #0.0 : mono
  Input #0, dshow, from 'audio=Stereo Mix (Realtek High Definition Audio)':
    Duration: N/A, start: 11732.800000, bitrate: 705 kb/s
      Stream #0:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (pcm_s16le (native) -&gt; pcm_s16le (native))
  Press [q] to stop, [?] for help
  Output #0, wav, to 'C:/users/antum/Videos/Captures/output-2019-02-13_10.52.17.456113800-audio.wav':
    Metadata:
      ISFT            : Lavf58.26.101
      Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
      Metadata:
        encoder         : Lavc58.47.100 pcm_s16le
  size=       0kB time=00:00:01.01 bitrate=   0.6kbits/s speed=   2x    
  size=       0kB time=00:00:01.51 bitrate=   0.4kbits/s speed= 1.5x    
  size=       0kB time=00:00:02.01 bitrate=   0.3kbits/s speed=1.33x    
  size=       0kB time=00:00:02.51 bitrate=   0.2kbits/s speed=1.25x    
  size=     256kB time=00:00:03.01 bitrate= 696.7kbits/s speed= 1.2x    
  size=     256kB time=00:00:03.51 bitrate= 597.7kbits/s speed=1.16x    
  size=     256kB time=00:00:04.01 bitrate= 523.0kbits/s speed=1.14x    
  size=     256kB time=00:00:04.51 bitrate= 465.1kbits/s speed=1.12x    
  size=     256kB time=00:00:05.01 bitrate= 418.6kbits/s speed= 1.1x    
  size=     256kB time=00:00:05.51 bitrate= 380.7kbits/s speed=1.09x    
  size=     512kB time=00:00:06.01 bitrate= 697.9kbits/s speed=1.09x    
  size=     512kB time=00:00:06.51 bitrate= 644.3kbits/s speed=1.08x    
  size=     512kB time=00:00:07.01 bitrate= 598.3kbits/s speed=1.07x    
  ...
  ...
  size=   20224kB time=00:03:55.01 bitrate= 705.0kbits/s speed=   1x    
  size=   20224kB time=00:03:55.51 bitrate= 703.5kbits/s speed=   1x    
  size=   20224kB time=00:03:56.01 bitrate= 702.0kbits/s speed=   1x    
  size=   20224kB time=00:03:56.51 bitrate= 700.5kbits/s speed=   1x    
  size=   20224kB time=00:03:57.01 bitrate= 699.0kbits/s speed=   1x    
  size=   20224kB time=00:03:57.51 bitrate= 697.5kbits/s speed=   1x    
  size=   20480kB time=00:03:58.01 bitrate= 704.9kbits/s speed=   1x    
  size=   20480kB time=00:03:58.51 bitrate= 703.4kbits/s speed=   1x    
  size=   20480kB time=00:03:59.01 bitrate= 701.9kbits/s speed=   1x    
  size=   20480kB time=00:04:00.01 bitrate= 699.0kbits/s speed=   1x    
  size=   20480kB time=00:04:00.51 bitrate= 697.6kbits/s speed=   1x    
  size=   20736kB time=00:04:01.01 bitrate= 704.8kbits/s speed=   1x    
  size=   20736kB time=00:04:01.51 bitrate= 703.4kbits/s speed=   1x    
  size=   20736kB time=00:04:02.01 bitrate= 701.9kbits/s speed=   1x    
  size=   20736kB time=00:04:02.51 bitrate= 700.5kbits/s speed=   1x    
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-13T19:21:13.643Z
Comments.Text: Are you using the same ffmpeg as months ago when it worked?
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-14T23:01:06.597Z
Comments.Text: I have upgraded to a newer version to see if it would fix the problem.
Comments.UserDisplayName: AntumDeluge
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-14T23:42:28.347Z
Comments.Text: If an old version worked and the new one is worse it could indicate a regression. If you are familiar with `git bisect` and compiling you could find the responsible commit, but it can be time consuming and tedious.
Comments.UserDisplayName: llogan
Tags: <ffmpeg><video-capture><screen-casting>
Title: Desktop Capture Has Become Choppy/Jerky with FFmpeg
UserDisplayName: AntumDeluge
ThreadText: # Desktop Capture Has Become Choppy/Jerky with FFmpeg
  
  (Asked by: username_0 on 2019-02-13)
  
  Recently, videos produced by capturing a window on my system using FFmpeg have become choppy/jerky, as if frames have been dropped or duplicated. FFmpeg will sometimes report that a number of frames were dropped when recording began, but not throughout the video. Videos I had recorded a few months ago did not suffer from this. Encoding speed reports to be between 1.0x & 0.996x.
  
  I suspected that the problem might have to do with system performance related to the hard drive. So I cleaned up junk files on my system & defragmented the drive. But the resulting video output did not change.
  
  Reading through [this thread](https://ffmpeg.org/pipermail/ffmpeg-user/2017-March/035518.html), one user recomends recording at 30 fps instead of 60. But I had no problem recording at 60 before.
  
  The dimensions of the window I am recording are 512x448. I record the audio & video in separate FFmpeg processes (this prevents audio drift).
  
  The following is an example portion of a script I use for recording:
  
  ```
  ffmpeg -hide_banner -rtbufsize 500M -thread_queue_size 512 -f dshow -ac 1 -i audio="<audio_device>" -c:a pcm_s16le audio-tmp.wav & APID=$!
  
  ffmpeg -hide_banner -rtbufsize 1500M -thread_queue_size 512 -f gdigrab -framerate 60 -i title="<window_name>" -c:v libx264 -preset ultrafast -qp 0 -x264opts keyint="1" video-tmp.mkv
  
  ```
  
  The entire script can be found [here](https://gist.github.com/username_0/75f63661c75cdc77c3497a3515b1b2fe/d3e7302128bd70c7df0913dde711c892aa4ec289).
  
  System specs:
  
  * [HP Pavilion 24-b217c](https://support.hp.com/us-en/document/c05381021)
  * **CPU:** Intel Core i5-7400T
    + 2.4GHz
    + 4 cores
  * **RAM:** 12GB
  * **GPU (hybrid):**
    + NVIDIA GeForce 930MX
    + 2GB dedicated RAM
    + Intel HD Graphics 630
  
  **Edit:** Here is the video output from the terminal:
  
  ```
  Input #0, gdigrab, from 'title=Mega Man Unlimited':
    Duration: N/A, start: 1550055137.876177, bitrate: 440427 kb/s
      Stream #0:0: Video: bmp, bgra, 512x448, 440427 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc
  Stream mapping:
    Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))
  Press [q] to stop, [?] for help
  [libx264 @ 000001d2881a15c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
  [libx264 @ 000001d2881a15c0] profile High 4:4:4 Intra, level 3.1, 4:4:4, 8-bit
  [libx264 @ 000001d2881a15c0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=1 keyint_min=1 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
  Output #0, matroska, to 'C:/users/antum/Videos/Captures/output-2019-02-13_10.52.17.456113800-video.mkv':
    Metadata:
      encoder         : Lavf58.26.101
      Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 512x448, q=-1--1, 60 fps, 1k tbn, 60 tbc
      Metadata:
        encoder         : Lavc58.47.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
  frame=14587 fps= 60 q=-1.0 Lsize= 1625062kB time=00:04:03.13 bitrate=54753.8kbits/s speed=   1x
  video:1624328kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.045149%
  [libx264 @ 000001d2881a15c0] frame I:14587 Avg QP: 0.00  size:114027
  [libx264 @ 000001d2881a15c0] mb I  I16..4: 100.0%  0.0%  0.0%
  [libx264 @ 000001d2881a15c0] coded y,u,v intra: 46.0% 44.6% 44.6%
  [libx264 @ 000001d2881a15c0] i16 v,h,dc,p: 77% 23%  0%  0%
  [libx264 @ 000001d2881a15c0] kb/s:54725.45
  
  ```
  
  And here is some of the audio output (output to file):
  
  ```
  Guessed Channel Layout for Input Stream #0.0 : mono
  Input #0, dshow, from 'audio=Stereo Mix (Realtek High Definition Audio)':
    Duration: N/A, start: 11732.800000, bitrate: 705 kb/s
      Stream #0:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
  Stream mapping:
    Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
  Press [q] to stop, [?] for help
  Output #0, wav, to 'C:/users/antum/Videos/Captures/output-2019-02-13_10.52.17.456113800-audio.wav':
    Metadata:
      ISFT            : Lavf58.26.101
      Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
      Metadata:
        encoder         : Lavc58.47.100 pcm_s16le
  size=       0kB time=00:00:01.01 bitrate=   0.6kbits/s speed=   2x    
  size=       0kB time=00:00:01.51 bitrate=   0.4kbits/s speed= 1.5x    
  size=       0kB time=00:00:02.01 bitrate=   0.3kbits/s speed=1.33x    
  size=       0kB time=00:00:02.51 bitrate=   0.2kbits/s speed=1.25x    
  size=     256kB time=00:00:03.01 bitrate= 696.7kbits/s speed= 1.2x    
  size=     256kB time=00:00:03.51 bitrate= 597.7kbits/s speed=1.16x    
  size=     256kB time=00:00:04.01 bitrate= 523.0kbits/s speed=1.14x    
  size=     256kB time=00:00:04.51 bitrate= 465.1kbits/s speed=1.12x    
  size=     256kB time=00:00:05.01 bitrate= 418.6kbits/s speed= 1.1x    
  size=     256kB time=00:00:05.51 bitrate= 380.7kbits/s speed=1.09x    
  size=     512kB time=00:00:06.01 bitrate= 697.9kbits/s speed=1.09x    
  size=     512kB time=00:00:06.51 bitrate= 644.3kbits/s speed=1.08x    
  size=     512kB time=00:00:07.01 bitrate= 598.3kbits/s speed=1.07x    
  ...
  ...
  size=   20224kB time=00:03:55.01 bitrate= 705.0kbits/s speed=   1x    
  size=   20224kB time=00:03:55.51 bitrate= 703.5kbits/s speed=   1x    
  size=   20224kB time=00:03:56.01 bitrate= 702.0kbits/s speed=   1x    
  size=   20224kB time=00:03:56.51 bitrate= 700.5kbits/s speed=   1x    
  size=   20224kB time=00:03:57.01 bitrate= 699.0kbits/s speed=   1x    
  size=   20224kB time=00:03:57.51 bitrate= 697.5kbits/s speed=   1x    
  size=   20480kB time=00:03:58.01 bitrate= 704.9kbits/s speed=   1x    
  size=   20480kB time=00:03:58.51 bitrate= 703.4kbits/s speed=   1x    
  size=   20480kB time=00:03:59.01 bitrate= 701.9kbits/s speed=   1x    
  size=   20480kB time=00:04:00.01 bitrate= 699.0kbits/s speed=   1x    
  size=   20480kB time=00:04:00.51 bitrate= 697.6kbits/s speed=   1x    
  size=   20736kB time=00:04:01.01 bitrate= 704.8kbits/s speed=   1x    
  size=   20736kB time=00:04:01.51 bitrate= 703.4kbits/s speed=   1x    
  size=   20736kB time=00:04:02.01 bitrate= 701.9kbits/s speed=   1x    
  size=   20736kB time=00:04:02.51 bitrate= 700.5kbits/s speed=   1x    
  
  ```
  
  **Tags:** ffmpeg, video-capture, screen-casting
  
  > **Comments:**
  > **username_1**: Are you using the same ffmpeg as months ago when it worked?  
  > **username_0**: I have upgraded to a newer version to see if it would fix the problem.  
  > **username_1**: If an old version worked and the new one is worse it could indicate a regression. If you are familiar with `git bisect` and compiling you could find the responsible commit, but it can be time consuming and tedious.  
  
  ---
  
  ## 0 answers
  
  