Bug Report Hooking with Battlefield 4 with OBS causes stutters

Mrwesth

New Member
Hello, First of all i would like to appoligise if what i post isnt the same issue

im having the same stream stuttering as badrobot has shown, look here: http://da.twitch.tv/swiftyxnap/c/3030347
im not having any problems with GPU or CPU loads, fair amount of power left and 60< fps on ultra preset. but stream is stuttering like crazy in preview stream everything looks fine but when i view the actual result .. well yeah look at the link :P
ive tried all sorts of things but i cant really figure out what i can do to make this go away. :(

besides this i have the same dx error when tapping out but that happens wether obs is open or not so guess that just an unrelated bug.

i can post the Log when i get home from work.
 

Bensam123

Member
Really weird Westh. I've never gotten that DX error without OBS being open. I'm not sure what's causing that jitter though. A log would definitely be helpful. You can also check out resource monitor and see what OBS and your processor are doing. That almost looks like the result of throttling, but your game would more then likely be stuttering like that too.


Sapiens said:
Dxtory can do this, but BF3 didn't exhibit any significant reduction of CPU/GPU usage from frame capping, so I wouldn't be surprised if BF4 behaved similarly.

How does DXtory keep the engine from rendering more frames? Capturing at less frames is different from having a frame rate cap for a engine.

Sapiens said:
dodgepong contributes far more to this forum and its users than either of us, and what he's posted so far in the topic has been pretty much spot on. He clarified about capture cards because there's a disturbing number of people who think a capture card alone will magically improve performance.

I have contributed a decent amount to the forums as well, I'm no longer active, but what was 'contributed' here was in no way helpful. I already clarified a page back that a capture card alone does not decrease the workload and I made it more clear. I also did not say it in a condescending manner.

Bensam123 said:
Looking at your thread Gartokk, your capture card doesn't do anything unless it's in another computer. You'll still get the encoding workload using a Live Gamer HD. OBS doesn't have support for the hardware encoding functionality. Those are pretty much identical problems as myself.

Compared with...

dodgepong said:
More like streaming and BF4 on the same computer do not play nice.

That doesn't seem to apply to anyone in this thread. The response I made to Gartokk is to another post when he linked it to here. This made me think he was looking down on people for trying to figure this out, as we all should have capture PCs cause that'll magically fix the problem at hand.
 

Mrwesth

New Member
Yeah, ive used Obs for all my games never had this problem, my cpu seems to me relaxed running at around 70% load with bf4 + streaming. (i7 4770k 4ghz).

Log in spoiler
15:12:49: Open Broadcaster Software v0.571b - 32bit (´・ω・`)
15:12:49: -------------------------------
15:12:49: CPU Name: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
15:12:49: CPU Speed: 3500MHz
15:12:49: Physical Memory: 4095MB Total, 4095MB Free
15:12:49: stepping id: 3, model 12, family 6, type 0, extmodel 1, extfamily 0, HTT 1, logical cores 8, total cores 4
15:12:49: monitor 1: pos={0, 0}, size={1920, 1080}
15:12:49: monitor 2: pos={-1920, 0}, size={1920, 1080}
15:12:49: Windows Version: 6.1 Build 7601 S
15:12:49: Aero is Disabled
15:12:49: -------------------------------
15:12:49: OBS Modules:
15:12:49: Base Address Module
15:12:49: 008A0000 OBS.exe
15:12:49: 50BE0000 OBSApi.dll
15:12:49: 50EA0000 DShowPlugin.dll
15:12:49: 711B0000 GraphicsCapture.dll
15:12:49: 6FF80000 NoiseGate.dll
15:12:49: 585B0000 PSVPlugin.dll
15:12:49: ------------------------------------------
15:12:49: Adapter 1
15:12:49: Video Adapter: NVIDIA GeForce GTX 780
15:12:49: Video Adapter Dedicated Video Memory: 3110797312
15:12:49: Video Adapter Shared System Memory: 1184104448
15:12:49: =====Stream Start: 2013-10-01, 15:12:49===============================================
15:12:49: Multithreaded optimizations: On
15:12:49: Base resolution: 1920x1080
15:12:49: Output resolution: 1280x720
15:12:49: ------------------------------------------
15:12:49: Loading up D3D10 on NVIDIA GeForce GTX 780...
15:12:49: ------------------------------------------
15:12:49: Audio Format: 48000hz
15:12:49: Playback device Default
15:12:49: ------------------------------------------
15:12:49: Using desktop audio input: Højttalere (Realtek High Definition Audio)
15:12:49: ------------------------------------------
15:12:49: Using auxilary audio input: Mikrofon (Realtek High Definition Audio)
15:12:49: ------------------------------------------
15:12:49: Audio Encoding: AAC
15:12:49: bitrate: 128
15:12:49: Using graphics capture
15:12:49: ------------------------------------------
15:12:49: Video Encoding: x264
15:12:49: fps: 45
15:12:49: width: 1280, height: 720
15:12:49: preset: veryfast
15:12:49: profile: high
15:12:49: keyint: 90
15:12:49: CBR: yes
15:12:49: CFR: no
15:12:49: max bitrate: 3500
15:12:49: buffer size: 3500
15:12:49: ------------------------------------------
15:12:49: MMDeviceAudioSource: Frequency for device 'Højttalere (Realtek High Definition Audio)' is 384000, samples per sec is 48000
15:12:49: MMDeviceAudioSource: Frequency for device 'Mikrofon (Realtek High Definition Audio)' is 352800, samples per sec is 44100
15:12:49: SharedTexCapture hooked
15:12:51: GraphicsCaptureSource::NewCapture: eliminating old capture
15:12:51: SharedTexCapture hooked
15:12:52: GraphicsCaptureSource::NewCapture: eliminating old capture
15:12:52: SharedTexCapture hooked
15:28:19: Exit signal received, terminating capture
15:31:41: Total frames encoded: 50938, total frames duplicated: 231 (0.45%)
15:31:41: Total frames rendered: 50868, number of late frames: 19 (0.04%) (it's okay for some frames to be late)
15:31:41:
15:31:41: Profiler time results:
15:31:41:
15:31:41: ==============================================================
15:31:41: video thread frame - [100%] [avg time: 0.542 ms] [children: 0.369%] [unaccounted: 99.6%]
15:31:41: | scene->Preprocess - [0.369%] [avg time: 0.002 ms]
15:31:41: GPU download and conversion - [100%] [avg time: 0.214 ms] [children: 85%] [unaccounted: 15%]
15:31:41: | flush - [60.7%] [avg time: 0.13 ms]
15:31:41: | CopyResource - [23.4%] [avg time: 0.05 ms]
15:31:41: | conversion to 4:2:0 - [0.935%] [avg time: 0.002 ms]
15:31:41: Convert444Threads - [100%] [avg time: 0.397 ms] [children: 98.7%] [unaccounted: 1.26%]
15:31:41: | Convert444toNV12 - [98.7%] [avg time: 0.392 ms]
15:31:41: encoder thread frame - [100%] [avg time: 0.936 ms]
15:31:41: ==============================================================
15:31:41:
15:31:41:
15:31:41: Profiler CPU results:
15:31:41:
15:31:41: ==============================================================
15:31:41: video thread frame - [cpu time: avg 0.082 ms, total 4196.43 ms] [avg calls per frame: 1]
15:31:41: | scene->Preprocess - [cpu time: avg 0 ms, total 31.2 ms] [avg calls per frame: 1]
15:31:41: GPU download and conversion - [cpu time: avg 0.023 ms, total 1185.6 ms] [avg calls per frame: 1]
15:31:41: | flush - [cpu time: avg 0.008 ms, total 436.801 ms] [avg calls per frame: 1]
15:31:41: | CopyResource - [cpu time: avg 0.007 ms, total 374.401 ms] [avg calls per frame: 1]
15:31:41: | conversion to 4:2:0 - [cpu time: avg 0.001 ms, total 62.4 ms] [avg calls per frame: 1]
15:31:41: Convert444Threads - [cpu time: avg 0.281 ms, total 28610.6 ms] [avg calls per frame: 2]
15:31:41: | Convert444toNV12 - [cpu time: avg 0.279 ms, total 28376.6 ms] [avg calls per frame: 2]
15:31:41: encoder thread frame - [cpu time: avg 0.339 ms, total 17300.5 ms] [avg calls per frame: 1]
15:31:41: ==============================================================
15:31:41:
15:31:41: =====Stream End: 2013-10-01, 15:31:41=================================================
15:31:46: =====Stream Start: 2013-10-01, 15:31:46===============================================
15:31:46: Multithreaded optimizations: On
15:31:46: Base resolution: 1920x1080
15:31:46: Output resolution: 1280x720
15:31:46: ------------------------------------------
15:31:46: Loading up D3D10 on NVIDIA GeForce GTX 780...
15:31:47: ------------------------------------------
15:31:47: Audio Format: 48000hz
15:31:47: Playback device Default
15:31:47: ------------------------------------------
15:31:47: Using desktop audio input: Højttalere (Realtek High Definition Audio)
15:31:47: ------------------------------------------
15:31:47: Using auxilary audio input: Mikrofon (Realtek High Definition Audio)
15:31:47: ------------------------------------------
15:31:47: Audio Encoding: AAC
15:31:47: bitrate: 128
15:31:47: Using graphics capture
15:31:47: ------------------------------------------
15:31:47: Video Encoding: x264
15:31:47: fps: 45
15:31:47: width: 1280, height: 720
15:31:47: preset: veryfast
15:31:47: profile: high
15:31:47: keyint: 90
15:31:47: CBR: yes
15:31:47: CFR: no
15:31:47: max bitrate: 3500
15:31:47: buffer size: 3500
15:31:47: ------------------------------------------
15:31:47: MMDeviceAudioSource: Frequency for device 'Højttalere (Realtek High Definition Audio)' is 384000, samples per sec is 48000
15:31:47: MMDeviceAudioSource: Frequency for device 'Mikrofon (Realtek High Definition Audio)' is 352800, samples per sec is 44100
15:31:48: Using RTMP service: Twitch / Justin.tv
15:31:48: Server selection: rtmp://live-ams.justin.tv/app
15:31:48: Interface: Killer e2200 PCI-E Gigabit Ethernet Controller (NDIS 6.20) (ethernet, 1000 mbps)
15:31:49: Completed handshake with rtmp://live-ams.justin.tv/app in 394 ms.
15:31:50: SO_SNDBUF was at 8192
15:31:50: SO_SNDBUF is now 65536
15:31:59: SharedTexCapture hooked
15:32:04: RTMPPublisher::Socketloop: Increasing send buffer to ISB 131072 (buffer: 0 / 463872)
15:32:07: GraphicsCaptureSource::NewCapture: eliminating old capture
15:32:07: SharedTexCapture hooked
15:32:07: GraphicsCaptureSource::NewCapture: eliminating old capture
15:32:07: SharedTexCapture hooked
15:32:09: RTMPPublisher::Socketloop: Increasing send buffer to ISB 262144 (buffer: 0 / 463872)
15:34:30: Exit signal received, terminating capture
15:34:43: SharedTexCapture hooked
15:34:46: GraphicsCaptureSource::NewCapture: eliminating old capture
15:34:46: SharedTexCapture hooked
15:34:46: GraphicsCaptureSource::NewCapture: eliminating old capture
15:34:46: SharedTexCapture hooked
15:35:18: Capture window 0x00040A56 invalid or changing, terminating capture
15:35:30: SharedTexCapture hooked
15:35:30: GraphicsCaptureSource::NewCapture: eliminating old capture
15:35:30: SharedTexCapture hooked
15:41:11: RTMPPublisher::Socketloop: Increasing send buffer to ISB 524288 (buffer: 0 / 463872)
16:19:22: Exit signal received, terminating capture
16:19:45: Total frames encoded: 129520, total frames duplicated: 1519 (1.17%)
16:19:45: Number of frames skipped due to encoder lag: 4 (0.00%)
16:19:45: Total frames rendered: 129135, number of late frames: 326 (0.25%) (it's okay for some frames to be late)
16:19:46: RTMPPublisher::SocketLoop: Graceful loop exit
16:19:46: Average send payload: 8105 bytes, average send interval: 17 ms
16:19:46: Number of times waited to send: 0, Waited for a total of 0 bytes
16:19:46: Number of b-frames dropped: 0 (0%), Number of p-frames dropped: 0 (0%), Total 0 (0%)
16:19:46: Number of bytes sent: 1307214368
16:19:46:
16:19:46: Profiler time results:
16:19:46:
16:19:46: ==============================================================
16:19:46: video thread frame - [100%] [avg time: 0.147 ms] [children: 1.36%] [unaccounted: 98.6%]
16:19:46: | scene->Preprocess - [1.36%] [avg time: 0.002 ms]
16:19:46: GPU download and conversion - [100%] [avg time: 0.535 ms] [children: 78.9%] [unaccounted: 21.1%]
16:19:46: | flush - [47.7%] [avg time: 0.255 ms]
16:19:46: | CopyResource - [30.5%] [avg time: 0.163 ms]
16:19:46: | conversion to 4:2:0 - [0.748%] [avg time: 0.004 ms]
16:19:46: Convert444Threads - [100%] [avg time: 0.413 ms] [children: 99%] [unaccounted: 0.969%]
16:19:46: | Convert444toNV12 - [99%] [avg time: 0.409 ms]
16:19:46: encoder thread frame - [100%] [avg time: 0.868 ms]
16:19:46: ==============================================================
16:19:46:
16:19:46:
16:19:46: Profiler CPU results:
16:19:46:
16:19:46: ==============================================================
16:19:46: video thread frame - [cpu time: avg 0.014 ms, total 1825.21 ms] [avg calls per frame: 1]
16:19:46: | scene->Preprocess - [cpu time: avg 0 ms, total 78.001 ms] [avg calls per frame: 1]
16:19:46: GPU download and conversion - [cpu time: avg 0.019 ms, total 2542.82 ms] [avg calls per frame: 1]
16:19:46: | flush - [cpu time: avg 0.008 ms, total 1045.21 ms] [avg calls per frame: 1]
16:19:46: | CopyResource - [cpu time: avg 0.006 ms, total 780.006 ms] [avg calls per frame: 1]
16:19:46: | conversion to 4:2:0 - [cpu time: avg 0 ms, total 31.2 ms] [avg calls per frame: 1]
16:19:46: Convert444Threads - [cpu time: avg 0.159 ms, total 41075.1 ms] [avg calls per frame: 2]
16:19:46: | Convert444toNV12 - [cpu time: avg 0.158 ms, total 40903.5 ms] [avg calls per frame: 2]
16:19:46: encoder thread frame - [cpu time: avg 0.262 ms, total 33961.4 ms] [avg calls per frame: 1]
16:19:46: ==============================================================
16:19:46:
16:19:46: =====Stream End: 2013-10-01, 16:19:46=================================================


Last game capture log:
2013-10-01, 15:35:28: we're booting up:
15:35:28: DXGI Present
15:35:28: (half life scientist) everything.. seems to be in order
15:35:30: DXGI: Found D3D 11
15:35:30: setting up d3d11 data
15:35:30: ---------------------- Cleared D3D11 Capture ----------------------
15:35:30: found dxgi format (dx11) of: 28, size: {1920, 1080}, multisampled: false
15:35:30: DoD3D11Hook: success
15:35:30: ---------------------- Cleared D3D11 Capture ----------------------
15:35:30: DXGI: Found D3D 11
15:35:30: setting up d3d11 data
15:35:30: ---------------------- Cleared D3D11 Capture ----------------------
15:35:30: DoD3D11Hook: success
15:35:30: successfully capturing d3d11 frames via GPU
16:19:11: ---------------------- Cleared D3D11 Capture ----------------------

Hope this helps :)

/mrWesth
 

Bensam123

Member
So a bit of googling around and I found the command to reduce the FPS in the engine (not with a 3rd party program).

gametime.maxvariablefps 60

Set the last variable to whatever you want. A little bit of testing I found the game normally gobbled around 60% of my processor. Setting it to 30 reduced it to about 30%, depending on the situation. This massively reduced stutters in the game and made it playable. Setting it to 20 further reduced CPU utilization, but I still had the occasional spike that would drive frame times up.

At 20 fluidity is pretty compromised, but the major spikes are almost completely gone. At this point I had about 40% utilization of my processor for my whole system, so this issue is not related to my CPU getting stomped by the game (not sure about other people).

At 20 there are still spikes and usage would occasionally get driven up to 40% during stutters or game events, whatever is happening in the background that's causing the major hitches. Either way it's almost a steady 20fps so it's playable while streaming.

I'm pretty sure this 'fix' would also work for people who are experiencing hitching without streaming as it tones down the frequency and potency of the spikes. I'm sure there is some nasty bug in Dice's code behind the scenes, but for now limiting the engine seems like the best bet.


I'm not entirely sure how you can 'cap' a games FPS with a third party program. In order to do that it would have to communicate with the game engine itself in order to tell it to turn down the FPS and I'm pretty sure the majority of programs aren't advanced enough for that (or integrated enough). The only thing I can think of is it artificially 'caps' the FPS by limiting how often a frame is drawn, sort of like a artificial vsync. The engine will still draw them as fast as possible (or told internally), you simply wont see the frames over Xfps. Hence why 'capping' BF3 with DXtory didn't do anything for CPU utilization, it wasn't doing anything to the game engine, but only the display of frames.
 

Krazy

Town drunk
I played/streamed BF4 for an hour or two earlier today, and honestly didn't notice any issues. When explosions and stuff were happening I had some noticeable frame drops, but nothing major, nothing that made things unplayable. Even while streaming I was able to stay above 45FPS most of the time on a mix of High/Ultra settings (with no AA or HBAO). Frankly, I didn't notice that much of a performance difference when I switch to QuickSync. Had FPS monitor up the whole time to check.
 

Bensam123

Member
Yeah a engine framerate cap is not Vsync, such as the command I listed. Krazy that's really weird.

I have noticed that this bug doesn't happen to everyone. Some people with super good systems have the same stuttering issues, some with really crappy systems don't have any at all. Intel or AMD, AMD or Nvidia, it doesn't matter. I assume you just got lucky Krazy. Watching your VOD definitely makes it seem like it's working fine and dandy.
 

dodgepong

Administrator
Community Helper
For science, I tried streaming BF4 yesterday at 800p30. I was running the game at 1920x1200 at near-ultra settings with my GTX 680 4GB and my 3770k. I was able to hook the game just fine, though my framerate fluctuated from a high of 80 to a low of 25. CPU usage was between 60% and 85%.
 

cvax

Member
So for us SLI guys we have to cap the frames to prevent the stream stuttering? Note: only my recorded stream is stuttering and not the actual game.

perfoverlay.drawfps 1 shows I have about 100fps.
 

Bensam123

Member
I was able to test this out again today. The game runs just fine without OBS running, but as soon as I try capturing the game it gives me the some spikes as were in beta. They aren't nearly as bad, but they happen every 5-30 seconds.

Capping my FPS drops BF4s CPU usage, but it still spikes. So I don't believe this is related to CPU utilization as a FPS of 25 drops BF4s CPU utilization dramatically.

I tried gamecapture, window capture, and monitor capture. They all have varying degrees of these spikes.
 

Bensam123

Member
A bit more research it seems like the BF4 thread scheduler is really sensitive to timing. Whenever the encoding process was engaged the spikes would come regardless of how much CPU is being used by BF4. Turning up the resolution in OBS (and using more CPU) made them much worse, turning it down made them better, but there were still stutters regardless (even with OBS sitting at about 5% processor usage while encoding).

The most successful attempt I had at reducing these spikes was moving OBS to core 7/8 on my processor via affinity. I tried moving BF4 to cores 1-6, but this resulted in pretty hardcore jitter even if it completely removed the big spikes. I'm guessing BF4 sets how many cores it runs on when the game opens and if you force it to less it really messes up the internal timing. I haven't found a manual option to set the game to a certain number of cores.

It's quite weird, I can only surmise the way OBS is dealing with threads isn't meshing well with BF4 and my processor, a 8350. I'm sure this doesn't apply to everyone, but it's definitely worth reporting in. I tried unticking 'multithreaded optimizations' but it didn't do anything.
 

Bensam123

Member
It still does it. Even reducing OBS to 3x downscale, where it's using about 4% of my processor it still causes spikes (although the frequency of the spikes is reduced).

Curiously, are the people who don't have problems with streaming BF4 using Windows 8 or Windows 7? I'm currently on W7, I've heard W8 has a better thread scheduler...
 
Top