Recording stutters on keyframes

Marsh

New Member

OBS is stuttering in the recording but not in gameplay, with no missed or skipped frames. I've tried for months to get this fixed, even building a new computer and upgrading from win7 to 11, but the problem remains. I'm recording in 4k, with low overhead settings to later get encoded after editing.

One thing I can say is that it seems related to keyframes. The stutter happens on cue with whatever the keyframes are set at. So if it's set to 2 seconds, you get a stutter every 2 seconds. If you disable keyframes with keyint=0, the problem seems to go away. But that makes the file sizes about 5x bigger, and they were already significant (around 70gb each.)

Things I have tried:

-game mode/no game mode
-nvenc/no nvenc
-gsync/no gsync
-set desktop refresh to 60/144
-limit capture framerate/no limit
-mp4/mkv
-admin/no admin
-crf/cbr
-slower/faster cpu presets
-profile, tune/no profile, tune
-recording directly to very fast nvme
-switched from win7 to win11
-built 100% new computer

The game is Factorio. I don't see the problem in other games, but it's possible the 2D style of Factorio makes it easier to see the 1 frame stutter. It doesn't actually stutter in game, only the output file. The OBS window will look fine, then I check the video recording after the fact and it's got stutters.

Using Factorio's debug overlay, I don't see anything that would imply it's the source of the stutter. Average frame time is about 5ms, and the spikes are well below 16ms. Both computers performed similarly with Factorio. Removing all mods and starting a new game drops frame time to 0.13ms, but the recording stutters are still there.

The computer:

10900k no o/c
3080ti no o/c
64gb 4000mhz
2tb 980 pro nvme
win11
15-20% cpu utilization by encoder

The old computer with the same problem:

7700k no o/c
1080 no o/c
32gb 3200mhz
1tb 970 pro nvme
win7
40-50% cpu utilization by encoder
 

PaiSand

Active Member
Try using output simple mode and select one of the presets for recording.
Please review the analyser and follow its recommendations/directions:
 

BK-Morpheus

Active Member
I would disable Windows Game DVR and run OBS as admin.
Keyframes are best if left on 0 (=Auto).
If you want to stream on twitch, you are limited/forced to use CBR and keyframes every 2 seconds, but if you are not limited, go with CRF and auto keyframes.

The log itself shows now major problems, It's also possible that high bitrate (200.000kbit/s or crf 18) is problematic for the mediaplayer to playb the file.
Maybe just for testing, try a recording with CRF 28.
Also one suggestion: No matter the CPU core count, I would always recommend to use NVENC (new) if the GPU is an RTX model, because the quality will be on par with x264 on fast or even medium preset without any big impact on the system.
 

Marsh

New Member
Try using output simple mode and select one of the presets for recording.
Please review the analyser and follow its recommendations/directions:
Simple output didn't help. I've already tried the analyzer suggestions.

I would disable Windows Game DVR and run OBS as admin.
Keyframes are best if left on 0 (=Auto).
If you want to stream on twitch, you are limited/forced to use CBR and keyframes every 2 seconds, but if you are not limited, go with CRF and auto keyframes.

The log itself shows now major problems, It's also possible that high bitrate (200.000kbit/s or crf 18) is problematic for the mediaplayer to playb the file.
Maybe just for testing, try a recording with CRF 28.
Also one suggestion: No matter the CPU core count, I would always recommend to use NVENC (new) if the GPU is an RTX model, because the quality will be on par with x264 on fast or even medium preset without any big impact on the system.
I've already tried various combinations of your recommendations. Bit rate isn't an issue. NVENC consumes GPU resources. I'm gaming at 4K which is almost universally GPU limited, so there are plenty of CPU resources left over to encode while the GPU is very busy.

After doing about 100 tests I've made some progress, but I have not fixed the problem. It seems like a lot of sources can cause random stutters. Here's what I've changed:

I've locked down the keyframe stutters to the video player I was using, VLC. I can't figure out a setting to avoid the keyframe stutters, but other players work. One thing all the players share is random stutters, regardless of video file. I even encoded them to a youtube friendly 1080p output. I'm wondering if stuttering is a part of life when it comes to video files, and we just don't notice it because it's hidden in the fray of movement in a game. But regardless, I replayed the files in so-mo (frame by frame) several times to confirm actual stutters exist in the video files, and they do. The video players work best when allowed to play the file without interruption. When you do seeking, it can get "off" and start stuttering. I tested a Linux computer which also suffered from "seek induced stuttering." So from now on I do frame-by-frame to confirm stutters are in the video file.

I tried playing and recording directly from a secondary 1080p monitor, and I noticed it had a lot less stuttering than my main 4k screen, which hinted me towards thinking some monitors suffer from stuttering more than others. Factorio is a game that is sensitive to desktop refresh rare, so it was already set to 60. So set OBS to 59.94, and made a custom resolution/refresh rate for 59.941, which according to screen refresh testers gets me as close as possible to 59.94. Windows is a little glitchy when it comes to custom refresh rates, so I made one that was "59" as listed in windows, but the output was 59.94. Using a screen refresh tester was critical here to make sure the settings went through.

Additionally I used the "vsync=drop" custom muxer setting. My understanding is that this nukes the timestamps on every frame and rewrites them on output. Using the limit capture frame rate in the source settings did seem to help, for some reason. Also I found that windows game mode caused significant stuttering. None of the other settings I mentioned in the first post had any effect on the stuttering.

The above changes made a big difference to stuttering, but it's still there. Sometimes it gets real bad and others it seems almost fine. Even within Factorio, the problem is much worse when moving quickly (such as in a car on a road) as compared to walking around by foot. As mentioned above, this leads me to believe that stuttering might be a part of life with video files. Since Factorio is what is essentially a 2D image scrolling by (at 200 km/h in the case of my testing) the smallest of stutters are noticeable. Running around on foot in a 3D shooter, it would be hard to notice. Using the exact settings that previously caused stuttering when recording Factorio, seemingly were gone with Overwatch... but I suspect they were still there, just harder to notice with that kind of game.
 
Top