Question / Help Stabilizing stream. CBR questions

vognaR

Member
Since support on this forum is so awesome I would like to ask for a little advice.

I stream dota2 on twitch, I don't drop frames, everything on my side seems ok.
Now, some of my viewers say that they experience stuttering and can't really watch it. Because of that I tried CBR, it seemed to help but I wanted to set this up with crf=20 since it is improving picture quality pretty much from what I`ve seen. The problem is I'm not really sure if crf=20 is working the same way with CBR set to on and off. So here is my first question - what's the difference and is it ok to combine those 2 options?

Second thing - I read that CBR and ratetol are working pretty good together when it comes to stabilizing stream. So last night I tried everything I want together (CBR on, ratetol=20 and crf=20) I know these are advanced settings but my guess is that only this can help stabilize stream for some viewers. I was surprised because some viewers (more than usual) said that it stutters. So as emergency I set options back to crf=20 without CBR and ratetol.

Since I'm looking for a way to combine best picture quality with smooth stream for everyone (well, shocking... I know ;P) I would like to ask you - how would you combine those settings? I put here logs from both streams I mentioned (btw. can you tell me why quality=12 in option without CBR?) Big thanks in advance!

CBR ON:
Code:
Open Broadcaster Software v0.47a - 32bit (´・ω・`)
-------------------------------
CPU Name: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
CPU Speed: 3392MHz
Physical Memory:  4095MB Total, 4095MB Free
stepping id: 7, model 10, family 6, type 0, extmodel 1, extfamily 0, HTT 1, logical cores 8, total cores 4
Windows Version: 6.1 Build 7600 
Aero is Disabled
------------------------------------------
Adapter 1
  Video Adapter: NVIDIA GeForce GTX 550 Ti
  Video Adapter Dedicated Video Memory: 1025179648
  Video Adapter Shared System Memory: 3221385216
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using graphics capture
Using custom x264 settings: "ratetol=20 crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: yes
    CFR: no
    max bitrate: 2400
------------------------------------------
Total frames rendered: 179, number of frames that lagged: 0 (0.00%) (it's okay for some frames to lag)
=====Stream End=======================================================================
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Using custom x264 settings: "ratetol=20 crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: yes
    CFR: no
    max bitrate: 2400
------------------------------------------
Total frames rendered: 46, number of frames that lagged: 1 (2.17%) (it's okay for some frames to lag)
=====Stream End=======================================================================
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Using custom x264 settings: "ratetol=20 crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: yes
    CFR: no
    max bitrate: 2400
------------------------------------------
Using RTMP service: Twitch / Justin.tv
  Server selection: rtmp://live-ams.justin.tv/app
bufferTime: 2066, outputRateWindowTime: 1000, dropThreshold: 2566
RTMPPublisher::BufferedSend: Socket buffer is full (331319 / 331776 bytes), waiting to send 4097 bytes
RTMPPublisher::BufferedSend: Socket buffer is full (331319 / 331776 bytes), waiting to send 4097 bytes
RTMPPublisher::SocketLoop: Socket error, send() returned -1, GetLastError() 10054
Total frames rendered: 35218, number of frames that lagged: 12 (0.03%) (it's okay for some frames to lag)
okay, this is strange
librtmp error: WriteN, RTMP send error 10054 (79 bytes)
librtmp error: WriteN, RTMP send error 10038 (42 bytes)
Number of b-frames dropped: 66 (0.096%), Number of p-frames dropped: 0 (0%), Total 66 (0.096%)
=====Stream End=======================================================================
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Using custom x264 settings: "ratetol=20 crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: yes
    CFR: no
    max bitrate: 2400
------------------------------------------
Using RTMP service: Twitch / Justin.tv
  Server selection: rtmp://live-ams.justin.tv/app
librtmp error: RTMP_Connect0, failed to connect socket. 10060 (Unknown error)
Total frames rendered: 1054, number of frames that lagged: 1 (0.09%) (it's okay for some frames to lag)
Number of b-frames dropped: 0 (0%), Number of p-frames dropped: 0 (0%), Total 0 (0%)
=====Stream End=======================================================================
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Using custom x264 settings: "ratetol=20 crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: yes
    CFR: no
    max bitrate: 2400
------------------------------------------
Using RTMP service: Twitch / Justin.tv
  Server selection: rtmp://live-ams.justin.tv/app
bufferTime: 2393, outputRateWindowTime: 1000, dropThreshold: 2893
++++++++++++++++++++++++++++++++++++++++++++++++++++++
  New Scene
Using bitmap image
Using bitmap image
Using graphics capture
SharedTexCapture hooked
RTMPPublisher::BufferedSend: Socket buffer is full (331014 / 331776 bytes), waiting to send 2042 bytes
RTMPPublisher::BufferedSend: Socket buffer is full (331014 / 331776 bytes), waiting to send 2042 bytes
RTMPPublisher::BufferedSend: Socket buffer is full (330130 / 331776 bytes), waiting to send 2747 bytes
RTMPPublisher::BufferedSend: Socket buffer is full (330130 / 331776 bytes), waiting to send 2747 bytes
RTMPPublisher::BufferedSend: Socket buffer is full (327700 / 331776 bytes), waiting to send 4104 bytes
RTMPPublisher::BufferedSend: Socket buffer is full (330040 / 331776 bytes), waiting to send 4097 bytes
++++++++++++++++++++++++++++++++++++++++++++++++++++++
  New Scene
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Total frames rendered: 131930, number of frames that lagged: 43 (0.03%) (it's okay for some frames to lag)
RTMPPublisher::SocketLoop: Aborting due to bStopping
Number of b-frames dropped: 132 (0.051%), Number of p-frames dropped: 0 (0%), Total 132 (0.051%)
=====Stream End=======================================================================

Profiler results:

==============================================================
frame - [100%] [avg time: 3.766 ms] [avg calls per frame: 1] [children: 91.1%] [unaccounted: 8.87%]
| scene->Preprocess - [0.0797%] [avg time: 0.003 ms] [avg calls per frame: 1]
| video encoding and uploading - [91.1%] [avg time: 3.429 ms] [avg calls per frame: 1] [children: 31.7%] [unaccounted: 59.3%]
| | CopyResource - [0.478%] [avg time: 0.018 ms] [avg calls per frame: 0]
| | conversion to 4:2:0 - [0.0797%] [avg time: 0.003 ms] [avg calls per frame: 0]
| | call to encoder - [31%] [avg time: 1.166 ms] [avg calls per frame: 0]
| | sending stuff out - [0.212%] [avg time: 0.008 ms] [avg calls per frame: 0]
==============================================================

CBR OFF
Code:
Open Broadcaster Software v0.47a - 32bit (´・ω・`)
-------------------------------
CPU Name: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
CPU Speed: 3392MHz
Physical Memory:  4095MB Total, 4095MB Free
stepping id: 7, model 10, family 6, type 0, extmodel 1, extfamily 0, HTT 1, logical cores 8, total cores 4
Windows Version: 6.1 Build 7600 
Aero is Disabled
------------------------------------------
Adapter 1
  Video Adapter: NVIDIA GeForce GTX 550 Ti
  Video Adapter Dedicated Video Memory: 1025179648
  Video Adapter Shared System Memory: 3221385216
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Using custom x264 settings: "crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: no
    CFR: no
    max bitrate: 2400
    buffer size: 2400
    quality: 12
------------------------------------------
Total frames rendered: 22, number of frames that lagged: 1 (4.55%) (it's okay for some frames to lag)
=====Stream End=======================================================================
=====Stream Start=====================================================================
  Multithreaded optimizations: On
  Base resolution: 1920x1080
  Output resolution: 1280x720
------------------------------------------
Loading up D3D10...
Playback device Default
------------------------------------------
Using desktop audio input: Głośniki (Realtek High Definition Audio)
------------------------------------------
Using auxilary audio input: Mikrofon (Samson C01U              )
------------------------------------------
Audio Encoding: AAC
    bitrate: 192
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Using custom x264 settings: "crf=20"
------------------------------------------
Video Encoding: x264
    fps: 45
    width: 1280, height: 720
    preset: veryfast
    CBR: no
    CFR: no
    max bitrate: 2400
    buffer size: 2400
    quality: 12
------------------------------------------
Using RTMP service: Twitch / Justin.tv
  Server selection: rtmp://live-ams.justin.tv/app
bufferTime: 2070, outputRateWindowTime: 1000, dropThreshold: 2570
++++++++++++++++++++++++++++++++++++++++++++++++++++++
  New Scene
Using bitmap image
Using bitmap image
Using graphics capture
SharedTexCapture hooked
++++++++++++++++++++++++++++++++++++++++++++++++++++++
  New Scene
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
++++++++++++++++++++++++++++++++++++++++++++++++++++++
  New Scene
Using bitmap image
Using bitmap image
Using graphics capture
SharedTexCapture hooked
++++++++++++++++++++++++++++++++++++++++++++++++++++++
  New Scene
Using bitmap image
Using bitmap image
Using bitmap image
Using text output
Using text output
Using text output
Using text output
Using text output
Using text output
Using bitmap image
Total frames rendered: 391354, number of frames that lagged: 903 (0.23%) (it's okay for some frames to lag)
RTMPPublisher::SocketLoop: Aborting due to bStopping
Number of b-frames dropped: 0 (0%), Number of p-frames dropped: 0 (0%), Total 0 (0%)
=====Stream End=======================================================================

Profiler results:

==============================================================
frame - [100%] [avg time: 4.182 ms] [avg calls per frame: 1] [children: 92.9%] [unaccounted: 7.08%]
| scene->Preprocess - [0.0717%] [avg time: 0.003 ms] [avg calls per frame: 1]
| video encoding and uploading - [92.9%] [avg time: 3.883 ms] [avg calls per frame: 1] [children: 28.1%] [unaccounted: 64.7%]
| | CopyResource - [0.407%] [avg time: 0.017 ms] [avg calls per frame: 0]
| | conversion to 4:2:0 - [0.0717%] [avg time: 0.003 ms] [avg calls per frame: 0]
| | call to encoder - [27.5%] [avg time: 1.148 ms] [avg calls per frame: 0]
| | sending stuff out - [0.191%] [avg time: 0.008 ms] [avg calls per frame: 0]
==============================================================
 

Grimio

Member
CBR doesn't improve quality, and it's also kinda bad for streaming overall. It will pretty much always use up more bandwidth than VBR while delivering equal or worse quality(but not much).
So if you don't know if you absolutely need CBR, I would advise against using it.

The preset veryfast should be all you need, it's very well suited for streaming games and changing anything will significantly impact performance or quality(hint: you can't improve both).

The only thing you should do if you want better quality is to up the bitrate, but it looks like you have problems handling more than 2400 +20%(ratetol=20), so I wouldn't change that right now.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
Grimio - Bad for streaming? Forgive me, but you are somewhat mistaken here, if it were bad for streaming I wouldn't have added it. It does use more overall bandwidth, but the transmission is generally a bit more "stable". It prevents data from going wildly up and down is all, that's the primary reason for using it. It has its pros and cons, just like VBR. The general quality is about the same as VBR as well. The difference is fairly negligible from my own personal testing.

veryfast indeed is the best all-around preset for all single computer setups. Most direct way of increasing quality is indeed just bitrate/buffersize and CRF (if using VBR). The encoding presets can be useful but you really need to know what you're doing somewhat, hence why they're in advanced.
 

Grimio

Member
Sorry Jim, I tend to oversimplify things. VBR is just better overall for everyone involved if we leave out the fact that it tends to spike somewhat, which should be manageable with the new low latency mode.
 

vognaR

Member
guys, appreciate the feedback but that's not what i asked for...

@Grimio
i know what cbr does, you dont have to explain this. why did you write about preset? i never mentioned it and i already stream at veryfast so im also a bit confused why you write about it. also i dont have any problem handling even 5000 bitrate, i dont drop frames its about twitch and viewers who may have problems with high bitrates sometimes thats why i stick to 2400.

@Jim
you said "crf IF using vbr" - this is my question about - can i use cbr with crf=20? coz from what i understand now it's different than crf=20 + vbr.
i'd like to stabilize the stream by using cbr and have nice quality by setting crf=20. is there any problem with that? should i use only one of those at a time or?
 

Grimio

Member
Yeah, as far as I know CBR uses ratetol.
Vognar, sorry for the confusion. What I meant with my preset segment was that you can't really do much to improve quality significantly without absolutely destroying performance. Bitrate remains the only true variable here, there are no tricks around it. Also I meant to say that you shouldn't manipulate CRF directly unless you are doing local recording, as it will shoot you over the specified bitrate really fast.
 

vognaR

Member
CRF=20 will shoot me over the spicified bitrate? you mean over my 2400? thats first time i read something like that, is that correct? is it making my bitrate higher? Seems weird for me
 

Grimio

Member
Okay, I did some testing to be absolutely sure about this.

My test setup was:
CRF=18, to further increase the effect CRF has
Planetside2, very fast turning and looking around to maximize the required bitrate

As long as you have a buffer defined CRF will not overincrease the bitrate. here are my results:
bitrate: 2400 buffer: 3500 = 2400 kbit/s average
bitrate: 2400 buffer: 2400 = 2400 kbit/s average
bitrate: 2400 buffer: 0 = 14500 kbit/s average

While I'm not completely wrong, in this case I am :)
But let me try to explain why you still shouldn't use a custom CRF.

The quality 12 in the log is the representation of the CRF value. When you set the quality to 10, OBS will use a CRF of 22.
The lower you go with the CRF, the more bitrate will the encoder use to try and match the required per-frame quality and because we have only very limited bitrate the encoder will use up the buffer on the more static scenes and there will be less available when things start moving around, the result is an actual decrease in quality when it (arguably) matters the most.
 

vognaR

Member
Thanks for tests. For me crf=20 is perfect (game - Dota2) because I dont see any drawbacks of this and the picture is better (static and in motion). While crf=20 might not be the best setting for FPS games, for Dota2 seems to be great. Still thinking about CBR thou or a way for twitch not to stutter for some people who have good connection but it still stutters for them, nobody knows why...
 

Pugget

Twitch
Using CRF is a very bad idea. Indeed, it is mutually exclusive with the bitrate option, at least if one is passing parameters in the normal way to x264, and therefore incompatible with nal-hrd:cbr (i.e., "cbr"). One can cap the max buffer fill rate, which forces the CRF down, but you're still going to end up with very spiky bandwidth, which will cause your viewers to lag.

Twitch suggests everyone use CBR. CBR is your friend. Not only will it make it easier to find your maximum stable bitrate, but users will love you when your stream doesn't spike outside the current TCP window size on an already congested consumer ISP connection. There is much bad advice out there on CBR vs. VBR, most of it based on quality of the final stream. And it's true, VBR does look slightly better. But for the average streamer, who doesn't have the luxury to run numerous tests, the biggest quality gain you can have is not to lag.
 

XeiZ

Member
Another downside is you really "waste" alot of bandwidth on scenes that would require less bitrate.
But yea you question about why its quality 12 (dont know if it already was answered), its because you use crf=20 , 22 is quality 10 in obs and the setting is inverted, so lower crf = higher quality balance. crf 20 would equal qb=12 , crf 18 would be 13 etc.
But CBR actually (like already mentioned) ignores CRF but you should use ratetol which is really simple put just a percentage based tolerance for the bitrate, so 4000kbps bitrate with ratetol=25 would mean your encoder is allowed to use 3000 to 5000 kbps depending on the scene. (25 would probably defeat the purpose here, so you would use a smaller ratetol instead)
 

Grimio

Member
Thanks for makings us smarter, Pugget :)
I didn't think of the disadvantages VBR causes when it comes to planing and allocating resources(bandwidth) for a stream. Now that I think about it, it makes perfect sense why CBR, while causing more traffic than VBR, is still easier to plan and allocate for.
I was too focused on the actual bandwidth used to think about what matters more, which is actually being able to view the stream without interruption caused by a huge traffic spike.
 

Pugget

Twitch
Grimio said:
Thanks for makings us smarter, Pugget :)
I didn't think of the disadvantages VBR causes when it comes to planing and allocating resources(bandwidth) for a stream. Now that I think about it, it makes perfect sense why CBR, while causing more traffic than VBR, is still easier to plan and allocate for.
I was too focused on the actual bandwidth used to think about what matters more, which is actually being able to view the stream without interruption caused by a huge traffic spike.

^^

Yea, all of this is quite true as well. Load balancing 7000+ VBR streams is a headache. :-)
 

R1CH

Forum Admin
Developer
Does Twitch / Wowza output the stream to the clients at the maximum rate possible, or at the same rate as it comes in? I'm curious if using low latency mode (to achieve a non-spiky bandwidth profile) would pass on the benefits to the clients. If not, you could implement your own queuing system on the CDN nodes to achieve a similar effect provided there is enough buffer on the client to allow this.
 

Pugget

Twitch
I'm honestly not the person to ask; I'll ask our resident RTMP/wowza expert when I have a chance. That said, from what I've seen when looking at individual streams' bandwidth inside our network, I'd guess Wowza is sending it as fast as possible. I'm still somewhat dubious that delaying transmission to smooth out the bitrate would be a net benefit for a majority a viewers, particularly those with higher latency connections. I'd be interested in any references you may have, particularly those relating to RTT and packet loss when artificially smoothing transmission rate. It's far too late at night for me to imagine all the possible scenarios.
 

hilalpro

Member
ignoring any other factors wowza can only maintain same rate/shape if the latency is minimal to both ends with an optimal small enough tcp windowsize which is not a problem with auto tuning

one more thing, unnecessary delayed ack responses may happen over a tcp connection. check this out if you're looking to prevent the issue
http://support.microsoft.com/kb/823764
 

R1CH

Forum Admin
Developer
That only applies to Windows 2000 / Server 2003. Delayed ack isn't really a problem for streaming due to the high data rate.
 

hilalpro

Member
potentially to all of those
Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
Microsoft Windows Server 2003, Standard Edition (32-bit x86)
Microsoft Windows Server 2003, Web Edition
Microsoft Windows XP Home Edition
Microsoft Windows XP Professional
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Professional Edition
Microsoft Windows 2000 Server
Windows Server 2008 Datacenter without Hyper-V
Windows Server 2008 Enterprise without Hyper-V
Windows Server 2008 for Itanium-Based Systems
Windows Server 2008 Standard without Hyper-V
Windows Server 2008 Datacenter
Windows Server 2008 Enterprise
Windows Server 2008 Standard
Windows Web Server 2008
but it doesn't matter for obs since they're not supported

i like microsoft network monitor thought
 
Top