Question / Help NVENC custom buffer size / vbv

sneaky4oe

Member
So, I need to manually setup my nvenc buffer size so it's not bound to bitrate. Where's that option?
And how do I do this for x264 in OBS Studio too?
 

Fenrir

Forum Admin
You generally don't want to mess with the buffers. Change the rate control to CQP for NVENC and CRF for x264 instead.
 

sneaky4oe

Member
And if I actually want it? Seems that nginx can't accept stream with buffer size higher than 7mbit, and it's binded to bitrate by default...
 

Fenrir

Forum Admin
Where have you heard that? I regularly stream to my nginx-rtmp server at 30-40k bitrate with no issues.

Are you using the windows version of nginx?
 

Fenrir

Forum Admin
That guide is nearly 4 years old, I can't imagine any issues are still relevant today and as mentioned I stream well over 7k with no issues. What version of nginx and the rtmp module are you using? What happens when you disconnect? Have you checked the RTMP server logs for errors?
 

sneaky4oe

Member
nginx version: nginx/1.9.9
RTMP: https://github.com/arut/nginx-rtmp-module/releases/tag/v1.2.0
ffmpeg version 3.3.3-static http://johnvansickle.com/ffmpeg/

oem@Restreamer:/usr/local/nginx/logs$ cat error.log
2017/08/19 17:34:14 [error] 12641#0: *1 open() "/usr/local/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.0.33, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.55", referrer: "http://192.168.0.55/"
2017/08/19 17:41:47 [notice] 1770#0: signal process started
2017/08/19 17:41:47 [error] 1770#0: open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
2017/08/19 17:42:24 [notice] 1782#0: signal process started
2017/08/19 17:42:28 [notice] 1790#0: signal process started
2017/08/19 17:44:17 [alert] 1794#0: unknown process 1795 exited on signal 9
2017/08/19 17:44:24 [alert] 1794#0: unknown process 1832 exited on signal 9
2017/08/19 17:47:40 [alert] 1794#0: unknown process 1833 exited on signal 9
2017/08/19 17:47:48 [alert] 1794#0: unknown process 1869 exited on signal 9
2017/08/19 17:52:15 [alert] 1794#0: unknown process 1905 exited on signal 9
2017/08/19 17:53:10 [notice] 2058#0: signal process started
2017/08/19 17:54:06 [alert] 2064#0: unknown process 2068 exited on signal 9

oem@Restreamer:/usr/local/nginx/logs$ cat access.log
192.168.0.33 - - [19/Aug/2017:17:34:13 +0300] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.91 Safari/537.36 Vivaldi/1.92.917.39"
192.168.0.33 - - [19/Aug/2017:17:34:14 +0300] "GET /favicon.ico HTTP/1.1" 404 570 "http://192.168.0.55/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.91 Safari/537.36 Vivaldi/1.92.917.39"
192.168.0.33 [19/Aug/2017:17:44:17 +0300] PUBLISH "transcode-test" "1234" "" - 52306806 529 "" "FMLE/3.0 (compatible; FMSc/1.0)" (37s)
127.0.0.1 [19/Aug/2017:17:44:17 +0300] PUBLISH "tester" "1234" "" - 19972653 409 "" "" (32s)
127.0.0.1 [19/Aug/2017:17:44:17 +0300] PLAY "transcode-test" "1234" "" - 838 52306973 "" "" (37s)
192.168.0.33 [19/Aug/2017:17:44:24 +0300] PUBLISH "transcode-test" "1234" "" - 4230 409 "" "FMLE/3.0 (compatible; FMSc/1.0)" (4s)
127.0.0.1 [19/Aug/2017:17:44:24 +0300] PLAY "transcode-test" "1234" "" - 321 1296 "" "" (4s)
192.168.0.33 [19/Aug/2017:17:47:40 +0300] PUBLISH "transcode-test" "1234" "" - 805867506 409 "" "FMLE/3.0 (compatible; FMSc/1.0)" (3m 12s)
127.0.0.1 [19/Aug/2017:17:47:40 +0300] PUBLISH "tester" "1234" "" - 140906250 409 "" "" (3m 10s)
127.0.0.1 [19/Aug/2017:17:47:40 +0300] PLAY "transcode-test" "1234" "" - 8323 805866422 "" "" (3m 12s)
192.168.0.33 [19/Aug/2017:17:47:48 +0300] PUBLISH "transcode-test" "1234" "" - 18214034 409 "" "FMLE/3.0 (compatible; FMSc/1.0)" (5s)
127.0.0.1 [19/Aug/2017:17:47:48 +0300] PUBLISH "tester" "1234" "" - 2122040 409 "" "" (3s)
127.0.0.1 [19/Aug/2017:17:47:48 +0300] PLAY "transcode-test" "1234" "" - 478 18212630 "" "" (5s)
192.168.0.33 [19/Aug/2017:17:52:15 +0300] PUBLISH "transcode-test" "1234" "" - 1146182621 409 "" "FMLE/3.0 (compatible; FMSc/1.0)" (4m 23s)
127.0.0.1 [19/Aug/2017:17:52:15 +0300] PUBLISH "tester" "1234" "" - 199630584 409 "" "" (4m 21s)
127.0.0.1 [19/Aug/2017:17:52:15 +0300] PLAY "transcode-test" "1234" "" - 11713 1146181221 "" "" (4m 23s)
192.168.0.33 [19/Aug/2017:17:54:06 +0300] PUBLISH "transcode-test" "1234" "" - 215147088 529 "" "FMLE/3.0 (compatible; FMSc/1.0)" (52s)
127.0.0.1 [19/Aug/2017:17:54:06 +0300] PUBLISH "tester" "1234" "" - 36906572 409 "" "" (48s)
127.0.0.1 [19/Aug/2017:17:54:06 +0300] PLAY "transcode-test" "1234" "" - 2438 215147063 "" "" (52s)

oem@Restreamer:/usr/local/nginx/logs$ cat nginx.pid
2063

FFMPEG used to report bad package header right before stopping encoder.
 

Boildown

Active Member
There's a checkbox for "custom buffer size" actually. I missed it myself at first. Its not there for NVEnc though. You could try SuperFast or UltraFast x264 with that buffer to validate whether that fixes it or not. If you want that for NVEnc, it looks like you'd have to revert to OBS Classic.

If you can prove that custom buffer resolves the problem, then you could make a case to get it added for NVEnc. They probably removed it because the more settings there are, the more things people will do to screw up their OBS.
 
Last edited:

sneaky4oe

Member
the more settings there are, the more things people will do to screw up their OBS.

I thought the whole ideaz of OBS was not to make it simplier but rather give the user an opportunity to customize their stream better than analogues. AMD AMF encoder gives me all the control I wanted, and even more. Xaymar did a really good job with it there.

Getting back to custom buffer size, I've tried setting it in AMF and 20 minutes of stream were ok. I've also set chunk_size to 16777215 in nginx, as it's maximum recommended by adobe for streams.
And now I'm just going to test things out.
 

Fenrir

Forum Admin
Can you grab a log from OBS where a disconnect happens? I'm curious what is actually occurring.
 

Fenrir

Forum Admin
Just for reference, gonna put this here:

Code:
14:20:04.874: [x264 encoder: 'simple_h264_stream'] preset: veryfast
14:20:04.874: [x264 encoder: 'simple_h264_stream'] settings:
14:20:04.874:     rate_control: CBR
14:20:04.874:     bitrate:      15000
14:20:04.874:     buffer size:  15000
14:20:04.874:     crf:          0
14:20:04.874:     fps_num:      60
14:20:04.874:     fps_den:      1
14:20:04.874:     width:        1280
14:20:04.874:     height:       720
14:20:04.874:     keyint:       250
14:20:04.874: 
14:20:04.878: [Media Foundation AAC: 'simple_aac']: encoder created
14:20:04.878:     bitrate: 160
14:20:04.878:     channels: 2
14:20:04.878:     sample rate: 48000
14:20:04.878:     bits-per-sample: 16
14:20:04.878: 
14:20:04.878: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmp://stream.rachni.com/live/...
14:20:04.907: [rtmp stream: 'simple_stream'] Interface: Intel(R) I211 Gigabit Network Connection (ethernet, 1000 mbps)
14:20:05.400: [rtmp stream: 'simple_stream'] Connection to rtmp://stream.rachni.com/live/ successful
14:20:05.403: ==== Streaming Start ===============================================
14:35:34.811: [rtmp stream: 'simple_stream'] User stopped the stream
14:35:34.811: Output 'simple_stream': stopping
14:35:34.811: Output 'simple_stream': Total frames output: 53470 (55734 attempted)
14:35:34.811: Output 'simple_stream': Total drawn frames: 55796
14:35:34.811: Output 'simple_stream': Number of dropped frames due to insufficient bandwidth/connection stalls: 2264 (4.1%)
14:35:34.813: ==== Streaming Stop ================================================

This is to my nginx server. Well over 7k, 15 minute stream. Had a connection hiccup which is what the dropped frames are, but no disconnects, no issues with the server at all.

If your nginx server is dropping connections due to buffer sizes over 7k, I don't mean to sound rude, but you're doing something wrong.
 

sneaky4oe

Member
Did you setup static ip for your network card on your linux instead of dhcp?
Because alongside with nginx installation + rtmp morule building that's the only change that's in my clear ubuntu server build...
 

Fallen_Tyrael

New Member
I know this is an old-ish post but I have also been having the same issue for a few years. I am running nginx and ffmpeg on windows though, and I don't have the same hardware setup you do.

Currently though I am sending a 25000kbps to the server and trying OBS (on the server) to encode it and send it to twitch and so far I have been able to stream for 5 hours without issue, however upping the bitrate to 50k (which I would like to use) causes drops after an hour or so.

It would really help if we could have a buffer size for nvenc and so far I havent seen an explanation as to why we cant? I have tried putting maxrate= minrate= and bufsize= in custom settings but that didn't work :(
 

sneaky4oe

Member
I know this is an old-ish post but I have also been having the same issue for a few years. I am running nginx and ffmpeg on windows though, and I don't have the same hardware setup you do.

Currently though I am sending a 25000kbps to the server and trying OBS (on the server) to encode it and send it to twitch and so far I have been able to stream for 5 hours without issue, however upping the bitrate to 50k (which I would like to use) causes drops after an hour or so.

It would really help if we could have a buffer size for nvenc and so far I havent seen an explanation as to why we cant? I have tried putting maxrate= minrate= and bufsize= in custom settings but that didn't work :(

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:
23:05:56.764: WriteN, RTMP send error 10054 (4097 bytes)
23:05:56.764: WriteN, RTMP send error 10054 (35 bytes)
23:05:56.764: WriteN, RTMP send error 10038 (42 bytes)

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;
 
Top