(self-resolved) OBS with RTX nvenc causes FFMPEG to drop frames while GTX nvenc doesn't

sneaky4oe

Member
I didn't figure out where to post this as a bug report for ffmpeg, so posting here - maybe someone can advise.

Using gyan.dev ffmpeg build, streaming with OBS to local wowza, then capture with ffmpeg to downscale.
:START
ffmpeg -i rtmp://127.0.0.1/wowza/myStream -b:v 8000k -minrate 7600k -maxrate 7900k -bufsize 8200k -vcodec libx264 -tune grain -preset veryfast -profile:v high -s 1920x1080 -sws_flags lanczos -r 50 -g 100 -acodec copy -f flv rtmp://waw02.contribute.live-video.net/app/my_twitch_key
goto START
My CPU used to do this task fairly well with my previous video card, but I recently upgraded from a GTX 1650 to an RTX 3050 in my streaming server. With the same settings as before, I have huge frame drops inside ffmpeg (even if it's local file output).
1725748884255.png

1725748891670.png

I was playing with FFMPEG settings, and even having a superfast, low-res, low framerate stream was dropping frames, but the frame drops stopped when I switched OBS output from 60 to 50 FPS. This wasn't the case on a gtx video card - I could send source stream of 60 fps and ffmpeg was transcoding just fine

ffmpeg log 50 fps: https://pastebin.com/iqNwYd18

ffmpeg log 60 fps: https://pastebin.com/NdqMMcKE

Why is that so, and is there something I can do about it? I tried playing with codecs in ffmpeg, performance/scaling methods, even encoding it with GPU too, updated drivers to the latest available version, but only reducing OBS output to 50 helped. I can live with it for now, but I want the issue to be publically known to hopefully help fix it. I did have It in the past and opted in for streaming with 1080p source to deal with it, but I've been streaming to youtube lately and it is glorious at 1440p, and I keep records on it, so I want it to have better quality overall.

TLDR: upgraded videocard from gtx to rtx, now my ffmpeg can't do any type of transcoding to lower resolution and framerate of the stream with unchanged parameters inside OBS. Something changed in how OBS outputs stream I assume, as lowering source stream framerate to 50 allows ffmpeg to work again.
 
Last edited:

Tomasz Góral

Active Member
"-vcodec libx264" - this use CPU to encoding
Why you use OBS to stream with high quality and local rescale, it's better like rescaler in OBS ?

Why Wowza, it's very very big software, use nginx-rtmp easy and lightwear.

Of course you got current drivers (video), see older ffmpeg (now you use 7.0.2).

Both link are the same 50 fps "-r 50 -g 100".
 

sneaky4oe

Member
"-vcodec libx264" - this use CPU to encoding
Why you use OBS to stream with high quality and local rescale, it's better like rescaler in OBS ?

Why Wowza, it's very very big software, use nginx-rtmp easy and lightwear.

Of course you got current drivers (video), see older ffmpeg (now you use 7.0.2).

Both link are the same 50 fps "-r 50 -g 100".
OBS is used to stream to YouTube in full quality and record video in full quality locally with several audio tracks.
CPU encoding is desired there, since it gives better results than GPU encoding if you go above "faster" preset even for recent nvenc codecs according to my tests.

Wowza proved to work better with nvidia streams in general, while nginx rtmp works well only with amd encoded videos from OBS, and doesn't really allow 1440p as a stream having nonstop stream drops (I did lots of testing for it ~4 years ago). Nginx+rtmp also wasn't updated for a while afaik. Wowza in my usecase isn't really big, and it isn't bottlenecking my streams, while allowing me to stream with nvidia encoder and at 1440p.

Videocard drivers were updated yesterday, and ffmpeg was downloaded from master stable builds yesterday too.

Yes, I want 50 FPS at twitch while having main stream at 60 fps, since it allows for higher bitrate/frame resulting in identical image smoothness, while significantly increasing perceived sharpness.
 

koala

Active Member
upgraded videocard from gtx to rtx, now my ffmpeg can't do any type of transcoding to lower resolution and framerate of the stream with unchanged parameters inside OBS.
ffmpeg uses CPU only, no GPU, so there seems to be a change in your CPU usage so ffmpeg has less CPU resources for itself than before.
In case you upgraded your GPU to a more powerful one for improved gaming performance, and you're running the game on the same computer as everything else, you enabled your game to perform more sophisticated rendering. This better rendering usually causes game engines use more CPU power as well, for higher resolution textures, higher resolution graphics assets and for supplying the more powerful GPU with better/more graphics effects.
And this higher CPU usage from the game might be the reason there's not enough CPU resources any more to let ffmpeg do what it has done before.
 

sneaky4oe

Member
ffmpeg uses CPU only, no GPU, so there seems to be a change in your CPU usage so ffmpeg has less CPU resources for itself than before.
In case you upgraded your GPU to a more powerful one for improved gaming performance, and you're running the game on the same computer as everything else, you enabled your game to perform more sophisticated rendering. This better rendering usually causes game engines use more CPU power as well, for higher resolution textures, higher resolution graphics assets and for supplying the more powerful GPU with better/more graphics effects.
And this higher CPU usage from the game might be the reason there's not enough CPU resources any more to let ffmpeg do what it has done before.
I thought so too, but even if I use ffmpeg to transcode to 720p at veryfast 30 fps, I have 40% of CPU used by OBS and ffmpeg, I still have drops despite 60% of CPU is unused. It's not a CPU throttling for sure but rather is source stream issue, that changed when I changed GPU.

It's a standalone streaming server. All it does is running obs, ffmpeg and wowza. Nothing else changed except for a beefier GPU. ffmpeg also doesn't throw any drops when I stream OBS with 50 fps instead of 60, but it used to work great with 60 and gtx videocard. Game is not a factor here, as I game on a different computer.
 

koala

Active Member
You have a separate streaming server, running ffmpeg and wowza server, and you upgraded your GPU in your streaming server. What task does this GPU perform? Why was it upgraded? It seems neither being used by ffmpeg nor wowza.
 

sneaky4oe

Member
You have a separate streaming server, running ffmpeg and wowza server, and you upgraded your GPU in your streaming server. What task does this GPU perform? Why was it upgraded? It seems neither being used by ffmpeg nor wowza.
OBS uses it with nvenc to encode 1440p for youtube and local recording. It also can be used in nvidia broadcast to filter out webcam and avoid retracting my chromakey. With 60FPS and Nvidia broadcast, GPU is used at 80% while streaming OBS with 60 fps, and I still get drops without it working even if ffmpeg has a lower preset while OBS streams at anything above 50 fps at 1440p. With this usecase, even if I have lots of CPU headroom (60%) and some GPU headroom (20% while having nvidia broadcast running), ffmpeg will still drop frames.

So nvidia broadcast isn't a factor there as drops still happen when it's completely off. It was also installed when I was on GTX (but not used obviously). Reason to this was I gave my older RTX card to my wife. Back then I was outputting 1080p for both streams and records as 1440p didn't work for me with nginx and I didn't have wowza back then.
 

koala

Active Member
I'm sorry, but this is a too customized, complex and non standard setup to give any useful targeted advice. Too many components involved. This is way beyond this OBS support forum. The only connection I see between GPU upgrade and CPU usage is what I wrote above. I don't see OBS as reason for a ffmpeg or cpu performance issue after a non-CPU realated hardware upgrade.
 

sneaky4oe

Member
I'm sorry, but this is a too customized, complex and non standard setup to give any useful targeted advice. Too many components involved. This is way beyond this OBS support forum. The only connection I see between GPU upgrade and CPU usage is what I wrote above. I don't see OBS as reason for a ffmpeg or cpu performance issue after a non-CPU realated hardware upgrade.
There are no cpu/gpu bottlenecks, again. 1440p/60fps stream is something the card can do just fine while filtering webcam (and even running another gpu stream with lower resolution inside ffmpeg itself just for lulz).

The only real thing that changed is a more powerful GPU for encoding, and with that ffmpeg stopped working well with stream that comes from OBS.

I need to either understand how different is this new nvenc version and potentially revert it to an older implementation that's used for non-RTX cards inside OBS itself somehow (in which case this forum might be helpful), or figure out why ffmpeg won't work with higher intensity source stream with this new RTX nvenc codec while it worked well with GTX nvenc codec.

The rest of the setup, frankly, is irrelevant IMO, despite being very customized indeed.
 

sneaky4oe

Member
But to add insult to the injury, when I stream with x264 with ultrafast inside OBS itself at 1440p and 60 fps I also can't encode stream in ffmpeg properly, so I then wonder why it changed after GPU upgrade, and why it used to work well with older GPU... Encoding at 50 fps in OBS also results in stable ffmpeg stream with those settings - GPU is loaded to 60% at this state with nvidia broadcast in the background, and 40% with it disabled.
 

PaiSand

Active Member
From time to time I read people having issues after upgrading the GPU. All solved by reinstalling the GPU driver (clean install). Looks like something internal on the driver software got stuck on the previous card configuration and isn't updating.
On the other side, latest OBS versions have a new encoder for NVENC, specially aiming at the enhance broadcasting. You can read more about it on the release notes you can see on the github page, which you can access via the download page in here.
Most filters are also heavy on the CPU.

Attaching a log file in here may be interesting to see more in depth information that now you can only guess.
 

sneaky4oe

Member
From time to time I read people having issues after upgrading the GPU. All solved by reinstalling the GPU driver (clean install). Looks like something internal on the driver software got stuck on the previous card configuration and isn't updating.
On the other side, latest OBS versions have a new encoder for NVENC, specially aiming at the enhance broadcasting. You can read more about it on the release notes you can see on the github page, which you can access via the download page in here.
Most filters are also heavy on the CPU.

Attaching a log file in here may be interesting to see more in depth information that now you can only guess.
Hey, I did clean install (without DDU tho), but it didn't help there.
Attaching several last logs where I was trying to debug the situation mainly by switching to 50 fps and back
 

Attachments

  • logs.zip
    67 KB · Views: 11

sneaky4oe

Member
Well, I don't know what it was, but next stream ran as good as previous one with OBS at 60 and ffmpeg at 50. I guess it was just a bad boot...
Dropped frames didn't contribute to lags in the video itself anymore.
 
Top