Question / Help NVENC custom buffer size / vbv

Fallen_Tyrael

New Member
I've had a lot of tinkering around lately and currently seem to be more or less able to stream with 100 mbit/s, but I had to install a different RTMP module, and switch network card to gigabit mode. Otherwise I was unable to exceed 12 mbit/s.
nginx RTMP module I use now: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip
Current working setup for nginx on Linux is here: https://pastebin.com/viXQTKMh

There's also a recent tweak to ffmpeg I found recently that MIGHT help with this crap:


I've hed no time to test it out yet, but might help with my OBS drops when photoshop is launched (really?...)

Insert this to the beginning of your RTMP module.
  1. ping 1m;
  2. ping_timeout 10s;
  3. drop_idle_publisher 10s;

So are you able to stream at 100 mbit/s stable using nvenc? Because i'm finding that whatever I set my nvenc CBR bitrate to the buffer size seems to be forced to half that. For example if I set to 50 mbit/s and nothing is happening on screen the bitrate drops on obs to about 25 mbit/s however when things get busy all of a sudden it will spike to 70 mbit/s, and like you said on one of your replies above nginx never used to like anything over 7mbit and i think that its those large spikes and drops that might still be the issue in a way. But i cant be sure though if its network hardware, nginx or ffmepg that's the problem as this issue has been a real ballache to nail down over the years as it seems almost random, and not being able to fix a custom buffer size with nvenc doesn't help at all.

So what i am doing at the moment is starting from scratch and sending a x264, 100mbit bitrate with a 5mbit buffer stream of a high and low motion video to just nginx (no transcoding) and see if it drops network usage at all and after 1 hour (so far) i haven't seen a drop in network usage or a disconnect. I'm going to probably run this test for another hour and if all goes well ill up the buffer to 25mbit and see what happens.

Just part of me suspects its ffmpeg that can't handle really large sudden changes to bitrate when transcoding a live rtmp stream.
 
Last edited:

sneaky4oe

Member
Ffmpeg can handle those pretty well. In my testings I did spikes from 100 to 150 mbit/s, and it managed to do the good job. I believe that the issue is in both OBS and nginx RTMP module. It became way more stable after updating to a newer rtmp module and changing some other parameters. I still have some disconnects though, but it's OBS's fault, as they mostly happen when I have my photoshop opened or work in some specific programs. OBS unable to stream consistently to localhost nginx is a real shame.
 

Fallen_Tyrael

New Member
Yeah you could well be right... but to be fair on OBS NVidia hasn't exactly made it easy for 3rd party programs to use nvenc that well from what I have been reading. Because of some strange licensing scheme applied to it by NVidia.

As an example when I started encoding with nvenc on obs classic some time ago and I'm sure obs stuck to the CBR and buffer size I set, however after a driver update in the last year or so that all seemed to change along with an odd down clocking of my GPU memory by 500mhz every time I used nvenc (didn't down clock with x264).

So after looking up the down clocking issue I found out that NVidia forces a P2 power state when using CUDA: (https://forums.geforce.com/default/...ng-with-obs-causes-gpu-memory-to-downclock/1/) - check the 2nd reply from customer care. It makes me wonder what is going on deep down in the NVidia drivers considering the down clocking issue still hasn't been fixed with OBS.

Anyway I'm going to try doing a few more tweaks and updating my windows nginx rtmp as per your suggestion (Thank you by the way) and hopefully that will solve it or at least help.
 

sneaky4oe

Member
Don't worry. Great AMD AMF encoder behaves the same way witn nginx+ffmpeg, just a tiny bit more stable - it lasts 3-4 times longer before OBS gets disconnected. But it can't exceed 100 mbit/s for some reason.

Yeah, try another rtmp module and the 3 strings for module config, and tell me how it goes. I'd like to hear from someone with the same problem as mine if my fixes will actually help someone else. Also huge thanks to xaymar and fenrir for those tips. Not my own ideas. :-D
 

Fallen_Tyrael

New Member
Well yesterday I updated nginx and the module, however I haven't done any tweaks to the config yet, I also changed the keyframe interval in obs as it had reset itself and seemed to be causing issues.

But so far so good! I was able to stream at 50mbit/s to the server and transcode it for 5 hours without an issue. I will need to run a few more tests though to see if remains stable.
 

sneaky4oe

Member
Ok, please do some tests and report back to the thread. People should know if it's a working solution that fits everyone.
 

Fallen_Tyrael

New Member
I will do, but last nights test resulted in repeated disconnects just after 20 minutes but that seemed to be caused by having 2 instances of nginx running (whoops). Anyway I managed to stream for 4 hours until the next disconnect, it did reconnect and seem to remain connected and stable for another hour but I did have to restart ffmpeg.

So today I will add those lines you suggested and try again. I did also have a look at your config and I couldn't see what your worker_processes and worker_connections for nginx are?
 

sneaky4oe

Member
I didn't change anything but added rtmp module's config. The rest is unchanged.

Check if your stream resolution isn't above 1080p - it's crucial for stability in my case.
 

Fallen_Tyrael

New Member
Sorry for my slow reply, I haven't been doing much streaming since I last posted.
Anyway i am only sending a 1080p stream though nginx and after some tests with your settings i am still getting disconnects :( and they seem random, sometimes its happens after half an hour and sometimes it doesn't happen even after 6 hours of streaming.

Have you had any more problems at all?
 

sneaky4oe

Member
Yes, encoder was stopping randomly every once in a while complaining about bad package header (not every second as was with 1440p streaming). I've got myself a cheap rx460 amd card specifically for encoding, and now I stream with it. 4 days of testing, 0 disconnects. Looking forward to test more. Not telling it will fix issues for all, but that's what I did for now.
 
Top