Short Burst of Rendering / Encoding Lag when starting new local recording

I am having an issue where I get a small burst (like half a second) of rendering + encoding lag when I press "Start Recording" about 5~ seconds into the recording. The system then recovers perfectly and doesn't have any other issues for the duration of the recording.

Here is a sample log file from a time this happened: https://obsproject.com/tools/analyzer?log_url=https://obsproject.com/logs/zj5qFygI256LZ-Bf

When the above log file was generated I did not have any games running on my PC. I was simply displaying my USB webcam and USB capture card in OBS. My computer has fairly reasonable specs with an i7 8700k and an nvidia 2080 super utilizing nvenc encoding with the latest drivers installed - so I don't think hardware is the bottleneck.

Any ideas what might be causing this? Would really like to get this issue resolved.
 

dodgepong

Administrator
Community Helper
It's a little hard to tell with that log, as it has several recording sessions included, and the log does not include the profiling data at the end. To generate a cleaner log file, I recommend doing the following:

1. Start OBS
2. Perform your reproduction steps (press "Start Recording" and let the recording go for ~15 seconds)
3. Stop the recording
4. Close OBS
5. Re-open OBS and upload the "Last" log (rather than the "Current" log)

I would also be curious if the problem still occurred on a clean scene collection, just to be certain it isn't an issue with resource utilization.
 
So it doesn't lag every time I start recording, just sporadically.

I started and stopped a few recordings and generated the encoding lag again. Reloaded OBS and here is the last log file as requested: https://obsproject.com/tools/analyzer?log_url=https://obsproject.com/logs/9M06Lt_uHI9oHOUK

Let me know if there is anything else I can provide to help pin down the issue. Really want to get this addressed as it is negatively impacting my content on the regular.
 

dodgepong

Administrator
Community Helper
It's odd to me that it happens sporadically. Is the drive you're recording to a platter drive or an SSD?

It seems that the slowdown is coming from a rendering lag that spikes up with one or more sources taking too long to render. It's not clear which one is at fault. Again, I would be curious if this were reproduceable on a clean scene collection.

I do see that there appears to be an orphaned virtual camera output filter on your "cannon" source. I believe that filter comes from Exeldro's Virtual Cam Filter plugin, which doesn't appear to be loaded in this log. It may not be related, but is probably worth cleaning up.

Also, you might consider disabling psycho-visual tuning in your NVENC settings, which adds some load to the encoder without much of a noticeable benefit (at least in my opinion).
 
Using an m.2 ssd drive as my write target.

I did have a virtual camera plugin installed at one point, but removed it since I wasn't needing it anymore. How do I clean up whatever it left behind?

I'll look into changing your suggested nvenc setting. Thank you for the suggestions so far.
 

dodgepong

Administrator
Community Helper
I did have a virtual camera plugin installed at one point, but removed it since I wasn't needing it anymore. How do I clean up whatever it left behind?
Open the filters of your "cannon" source and delete the virtual cam filter from the filter list.
 

dodgepong

Administrator
Community Helper
Have you tested it on an empty scene collection?

(You can create a new scene collection while keeping your existing collection intact by going to Scene Collection > New. If you haven't given your current scene collection a name yet, you can first click the "Rename" option instead to give it a name.)
 
I haven't, but I'm also not sure how an empty scene helps with my issue. My PC should be powerful enough to run a video game while also using OBS, running a few video inputs while the only thing using the GPU being the encoder should be no problem.

Say it does work as expected on a new collection - how do I address the current issue? Do I rebuild all my scenes from scratch? If I add back in the stuff I need won't that likely get me back to exactly where I am now?
 

dodgepong

Administrator
Community Helper
It would confirm that the issue is related to a specific source or set of sources in your scene collection (perhaps a bug in a source plugin), as opposed to a bug somewhere in the output initialization codebase.

If the issue happens on a blank scene collection (or a barebones one) then we have a much simpler reproduction case and it will be easier to debug, because it narrows down the area of code to look through, and we can ignore the possibility of it being related to a source.

If it doesn't happen on a blank scene collection, then the problem will be more complex to track down, as it may involve duplicating your current scene collection and deleting sources one by one and re-testing until the problem goes away, so that we can identify which source is the problem source. Once we identify the problem source, we can test more narrowly to see if we can figure out what's going wrong.
 
Alrighty. Part of the problem is that this doesn't happen every time I start recording. Not being able to reproduce on command makes it difficult to narrow down.

I see the nvidia encoder says "new" on it. Is there a way to access the old one to see if that resolves it? I'm also going to try just switching to processor encoding, but feels like it would be a shame not to use the GPU I bought for explicitly this purpose.
 

dodgepong

Administrator
Community Helper
I see the nvidia encoder says "new" on it. Is there a way to access the old one to see if that resolves it?
Short answer: yes, you can force the new NVENC encoder to fall back to the old encoder by checking the "Rescale output" box while in Advanced output mode, even if you don't actually change the scale. The UI won't show that it's using the old encoder, but the log file will show "[jim-nvenc] scaling enabled, falling back to ffmpeg".

Context: The "old" NVENC used FFmpeg to perform the encoding, which meant that encoding required copying rendered frames from OBS on VRAM back to RAM for FFmpeg to encode. The "new" NVENC (aka jim-nvenc) keeps rendered frames on the GPU before sending them to the GPU encoder, and is much more performant as a result. The reason the old encoder is even still around is because it does not have the ability to rescale the output on the encoder side. FFmpeg does have this ability, and people made use of it so that they can record at one resolution and stream on a different resolution. But generally speaking, for performance reasons, we advise you not to use the old NVENC.
I'm also going to try just switching to processor encoding, but feels like it would be a shame not to use the GPU I bought for explicitly this purpose.
I think that's a fair sentiment, though I would be curious if the issue is still present on software encoding. My current operating theory is still that there's something strange going on with one or more of your sources somewhere. The reason I think this is because, in your last log, the recording session that exhibited the problem showed "Number of lagged frames due to rendering lag/stalls: 15", which means one or more of your sources was running slowly and was not getting back to the OBS renderer fast enough to generate a new frame in time, which caused the hitching. This is confirmed by the profiler, which shows that at least one cycle of tick_sources took more than 7 seconds to complete ("max=7133.35 ms"). tick_sources is the section of code that basically says "hey sources, we've gone enough time to get another frame, so each of you go ahead and give me your next frame so I can render a single frame with all your new updates".

Now that I'm looking more closely at your sources list, if I had to make a guess at which source is the problematic one, I would blame it on the "cannon" source, not because of the virtual camera filter, but because it's pulling its frames from the EOS Webcam Utility. Generally speaking, when you're getting video frames from a nicer DSLR or mirrorless camera, it's better to use the camera's HDMI output and use an HDMI capture card. The EOS Webcam Utility instead grabs frames from the camera over USB (often USB 2.0), which can be much slower and less performant, and possibly lower quality.

The main problem on the Canon side is that, to my knowledge, a large number of their cameras do not provide clean HDMI out from their HDMI out ports. I'd need to know the model of your camera to know if a) it's using USB 2.0 or 3.0, and b) if clean HDMI output is an option for it.

A quicker way to confirm if that source is the problematic one would be to completely delete the "cannon" source from all your scenes and see if you can still reproduce the issue. Again, I recommend duplicating your scene collection before doing this, so that you don't have to set everything back up again.
 
Last edited:
I'm using an EOS90D that supports HDMI out. I actually have a spare capture card around as well - I'll try setting it up via that instead of via USB and see if that solves the issue. Come to think of it I think this issue started around when I changed cameras, so that could very well be it.
 

dodgepong

Administrator
Community Helper
A quick Google suggests that the EOS 90D does indeed support clean HDMI output (selectable under the "HDMI info disp" setting). Also, it does indeed use USB 2.0 instead of USB 3.0, so grabbing frames from the camera via the EOS Webcam Utility could be slower or lower quality (if not both).
 
I do not appear to have options other than MJPEG for the video format. Do I need to do something to get other options here?
Screenshot 2021-07-25 140536.png


Capture device is this model: https://www.amazon.com/Capture-Stre...ture+card&qid=1627240023&s=electronics&sr=1-5

Used it in the past without issues.
 

dodgepong

Administrator
Community Helper
Before we start going down this rabbit hole, can you at least confirm that completely removing the source from all of your scenes fixes the issue? I wouldn't want to spend too much more time digging into this if it turns out to not actually be the issue.
 
I appreciate the back and forth, but I've just gone ahead and purchased an xsplit license. Issue doesn't seem to appear there after some testing, so if that works I'm just going to run with it.

Thanks for your time.
 
Top