Question / Help Nvenc/OBS RTMP FFmpeg disconnect

I need help...please...I've read and tried just about everything available on this stuff and I'm at my wits end here...I need someone that knows more than me to give me a hand please.

I'm using Nvenc/OBS to stream to Nginx/RTMP server and then FFmpeg to push the stream off to twitch. My Nvenc/OBS and/or FFmpeg will drop my stream randomly, it could be immediately, take a few minutes or a few hours but it usually happens at least once a day or more. Sometimes it seems to be on the FFmpeg side, other times it seems to be on the NVenc/OBS side.

I have reduced many of my errors on the FFmpeg side by changing the -bufsize from 6000k to 3000k and adding -max_muxing_queue_size 1024. Most of my issues now seem to be with the connection to the RTMP from Nvenc/OBS side. I believe I'm having a bandwidth issue on my network, despite lowering my bitrate significantly. It seem like the higher the bitrate I try to push from Nvenc/OBS and FFmpeg the more unstable the connection with the RTMP server becomes.

Here are some of the scenarios I am dealing with...
  • If I try to push say 25000 bitrate from Nvenc/OBS and then execute FFmpeg, the connection from Nvenc/OBS is disconnected usually instantly and the FFmpeg file freezes with no error.
  • Sometimes I can get the FFmpeg file to catch the Nvenc/OBS stream around 17000 bitrate but eventually the FFmpeg file will show an error and stop or Nvenc/OBS will disconnect.
  • When I reduce the bitrate to around 12500 from Nvenc/OBS I am almost always able to successfully execute the FFmpeg but randomly Nvenc/OBS will drop with no error on the FFmpeg file.
Most recently I connected flawlessly. Streamed for a few hours and randomly Nvenc/OBS disconnected with no error on the FFmpeg file.

My most recent log is attached along with a copy of my rtmp config file and a copy of the FFmpeg batch file I am executing. My hardware is...

Gaming PC:
AMD FX 8350
EVGA GTX 970 FTW+

Streaming PC:
AMD Phenom II x4 960T
Strix Radeon R9 380
 

Attachments

  • 2018-02-23 13-39-36.txt
    17.6 KB · Views: 40
  • nginx-obsforum.txt
    950 bytes · Views: 30
  • ffmpegobsforums.txt
    288 bytes · Views: 29

vapeahoy

Member
You can stream from gamepc at 500MBIT with rtmp no problem whatsoever if you have pc's that can handle it. Even beyond but 500MBIT is max default setting. I've done 2gbit, but i have the pure strength in hardware that can really handle it and still ask for more ass kicking.
The bandwidth is not an issue, but u must remember it should be encoded realtime and received. In order of magnitude you need severe processing power. And I can't stress that enough. Buffer size is your kink most likely, too large buffer on stream pc that needs to be emptied out and processed. I use atm 2500 on stream pc, about 7000 i think on gamepc, for 1080p u can stream at 20-25000, go less for 720, 10-15000.


Enable admin mode, switch to a dedicated INTEL nic if possible, b-frames 0 from stream pc, key interval damn high at 250 but maybe that was normal for nvenc i forget, x264 i use 120.
Do experiments with interrupts on your network card, i recommend u start with disabling everything. Try jumbo packets etc.
Prepare yourself for a good long reading/research if you're going with rtmp or ndi, ndi also has its issues and offers less control. There is much advice that can be given, but frankly, that would be one hell of a long post.
edit: When i had an fx 8350 I settled for really medium low end settings, it could barely handle it. Even on Ryzen as stream pc i've had tons of problems. If u can, get an all intel setup - i know thats easy to say but point is to get latencies as low as u can get it, which is especially important on amd. I've never had an issue on intel with rtmp.
 
Can anyone please take a look at this log and help me understand the disconnects and how to resolve them?
 

Attachments

  • 2018-02-26 15-19-01.txt
    32.6 KB · Views: 24
I just told u but whatever.

I'm trying to do the things I can and some of the things you are asking me to do are not possible.
  • OBS does not allow you to adjust the buffsize when streaming with Nvenc. I can turn the bufsize down on ffmpeg but I'm not really getting any errors there. They all seem to be coming from the RTMP server.
  • I adjusted the keyframe interval to 60. It was set to auto which gave me 250.
  • I can't afford to switch to an all Intel setup nor can I really afford any additional equipment. So, I'm exhausting all avenues before buying any hardware.
  • Apparently, "socket_thread_windows: Socket error, send() returned -1, GetLastError() 10054" means that the rtmp server is disconnecting me. So, I have started to work with settings on the RTMP server.

I noticed you tried to direct me on how to change settings in the other thread where someone was having basically an identical problem. Thank you.

Problem is when I put the following settings in:

"...ping 1m;
ping_timeout 10s;
drop_idle_publisher 10s;..."

I can place them like this and server starts up (tested and server still disconnected me):

"...rtmp {
ping 1m;
ping_timeout 10s;
drop_idle_publisher 10s;..."​

or like this and server starts up (tested and server still disconnected me):

"...server {
ping 1m;
ping_timeout 10s;
drop_idle_publisher 10s;..."​

but the server won't start when I plug them in like this:

"...application Nvenc {
ping 1m;
ping_timeout 10s;
drop_idle_publisher 10s;..."​

Am I doing something wrong or is there something else you can suggest to help me solve this? Thanks for the help.
 

vapeahoy

Member
Whats ur fps setting on video? if its 60, keyframe interval is 2 and should be 2 regardless -its a good setting, should be same on stream pc - twitch prefers it, keyint then becomes 120, but yeah it may differ on nvidia enc.
You should post your entire nginx.conf, it will be cleaner that way to help you.

edit also do a nginx -t , to test your config file. You should run this from a command line to read the output.
 
Whats ur fps setting on video? if its 60, keyframe interval is 2 and should be 2 regardless -its a good setting, should be same on stream pc - twitch prefers it, keyint then becomes 120, but yeah it may differ on nvidia enc.
You should post your entire nginx.conf, it will be cleaner that way to help you.

edit also do a nginx -t , to test your config file. You should run this from a command line to read the output.

My fps is 30 and the keyint becomes 60 for nvenc and ffmpeg. My nginx.conf file is attached to the original post. I have attached 3 separate files of what I was trying to describe above. nginx1.txt and nginx2.txt both launch nginx but nginx3.txt does not. Obviously none of them solve the disconnect issue.
 

Attachments

  • nginx1.txt
    1,012 bytes · Views: 32
  • nginx2.txt
    1,015 bytes · Views: 20
  • nginx3.txt
    1,018 bytes · Views: 17
...edit also do a nginx -t , to test your config file. You should run this from a command line to read the output.

Sorry for being illiterate but I don't exactly understand what this mean or rather how to do it. Could you please explain it in further detail and I'll give it a shot.
 
Sorry for being illiterate but I don't exactly understand what this mean or rather how to do it. Could you please explain it in further detail and I'll give it a shot.

Are you referencing a .bat file where I would write something like "nginx.exe -s stop" but instead use "nginx.exe -t test"?
 

vapeahoy

Member
open cmd.exe
cd nginxdirectory
nginx -t -c conf/nginx.conf, u can make a batch file if u like. It should look like this f.example:
Microsoft Windows [Version 10.0.16299.248]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd C:\nginx

C:\nginx>nginx -t -c conf/nginx.conf
nginx: the configuration file C:\nginx/conf/nginx.conf syntax is ok
nginx: configuration file C:\nginx/conf/nginx.conf test is successful
 

vapeahoy

Member
try cleaning up the formatting so nginx3 is same spaced as the other ones, format is perhaps quite sensitive to tab/spaces where they shouldnt be, as part of the syntax. I recommend notepad++ for editing.
 
try cleaning up the formatting so nginx3 is same spaced as the other ones, format is perhaps quite sensitive to tab/spaces where they shouldnt be, as part of the syntax. I recommend notepad++ for editing.

I did some reading on settings for the config file and the following can only be entered in on the server or rtmp level not the application level.

ping 1m;
ping_timeout 10s;
drop_idle_publisher 10s;
 
open cmd.exe
cd nginxdirectory
nginx -t -c conf/nginx.conf, u can make a batch file if u like. It should look like this f.example:
Microsoft Windows [Version 10.0.16299.248]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd C:\nginx

C:\nginx>nginx -t -c conf/nginx.conf
nginx: the configuration file C:\nginx/conf/nginx.conf syntax is ok
nginx: configuration file C:\nginx/conf/nginx.conf test is successful

Did it syntax is ok and test is successful!
 

vapeahoy

Member
I did some reading on settings for the config file and the following can only be entered in on the server or rtmp level not the application level.

ping 1m;
ping_timeout 10s;
drop_idle_publisher 10s;

Oh, I thought that much was obvious. Sorry. chunk_size 8192 is good, but heck even 128 can work too and i remember someone said they had great experience with that but idk what their hardware was. I use 8192 and i know some other nerds on here use that as well, but it by itself wouldnt be a problem as long as the data isnt overflown or so by too much at once. Really I think the big problem here is that you probably have to find the settings that work for your system.

This reminds me it would also be good to ask the nginx-rtmp module author what network card settings he'd recommend for pc to pc rtmp. Personally i just turn everything off, even tho i notice there are substantial changes with some on, it's the grand total of settings together that makes it work really well i think. I think i disabled interrupts on both pc's and just set the network buffer very high, but I havent had time to experiment with it now at very low buffer.
Also try disabling all kinds of power save states stuff for your pc's, turn off green ethernet etc.
 
I stepped down to 720p and everything seems to be good. I don't understand why it's fine at 720 and not 1080. I can use identical settings bitrate, filters, everything identical except the resolution changes. I dont have quality issues (i.e. dropped frames, lag, etc.) with either 720 or 1080 but I have connectivity issues when I use 1080. Anyone want to try and explain that?
 
Last edited:

vapeahoy

Member
Windows size too low for adapter or its dynamically allocated and your crap onboard can't keep up with the tcp requests fast enough.
 
Windows size too low for adapter or its dynamically allocated and your crap onboard can't keep up with the tcp requests fast enough.

At the moment I am downscaling with obs/nvenc. Tomorrow I am going to try streaming to the rtmp in 1080p60 then use FFmpeg -sws_flags spline to downscale to 720p60. If this works, will it narrow down what is the problem?

Do you know if my in game fps will take a hit when going from 720p60 to 1080p60?

It's my understanding that there should not be any difference in gaming performance.
 

vapeahoy

Member
Downscaling should work fine. I capture at 1080p60 atm and scale it to 720p60, where as then stream pc receives it as 720 and encodes it. It seems better that way then capturing at 1080, not scaling down. Even tho quality wise its better to capture at 1080p and re-encode at 720 with the stream pc downscaling it.
**At least i think so, i havent really tested if the quality suffers much, but logically i think it would. It just seems to perform smoother downscaling it at game pc and the streampc has an easier task and can be pushed harder. Which is the thing.
What would be great is to capture playback of f.ex 3dmark or a video at high fps/high bitrate, and test with various settings what performs best.

Your 970 should do a good job of capturing the game and scaling issues on there shouldn't be an issue with the built in nvidia encoder if that is the plan. Nvidia encoder is a dedicated chip on the graphics card so the penalty for doing it that way should be next to nothing. If that somehow is a problem, there is a defect on the gpu most likely. Nvidia encoder is very, very good. 10xx series is slightly better encoder then 900 series, but 11xx series soon so..
You can also consider capturing at a high bitrate at x264, 25000 for 1080p, and using ultrafast to send to stream pc. Testing unfortunately is the only way to figure out what works best. Cpu usage should be very minimal capturing at ultrafast and with a high bitrate it doesnt have so much compression to do and the stream pc will then have to deal with it, but u have less strain on the gaming pc.
Try custom buffer size of 7000, and not more on gaming pc if testing x264. You dont want to keep too much data and u dont want it dynamically allocated to an unknown setting. You want to know what you're using.

Dedicated gpu encoder need very little cpu power, but they need some. Kind of like network cards, which i mention because your doing pc to pc transfer, so dedicated nic's buffer really isnt used unless you'r hitting close to 100 percent cpu usage or very close, and a lot of the time. Buffer for network cards u should be able to set to a minimum, this should also slightly help pc to pc latency.
You want to have some cpu power reserved so u have room to work with.
Alternatively you can set affinity's for OBS and such, but i can't recall if u can set affinity for the nvidia encoding process itself, and i currently dont have time to check. It really shouldnt be a problem tho, I am simply saying its a possibility.
Also enable jumbo packets, really works, least for me.
 

alpinlol

Active Member
Not sure anymore but out of curiosity could you try your usual settings but just with a 6k bitrate from gaming -> streaming pc.

In general I would highly recommend using NDI+OBS on streaming PC which makes it way easier.
 
Top