Bug Report QuickSync Encoder Failure

Incalex

New Member
Hello,

On OBS Studio version 0.14.2 (64bit) on Windows 7 (64bit), the QSV encoder seems to randomly crash.

The "randomly" part is beacuse it happens after a random period of time. Worst I got is 2 minutes, best I got is almost one hour.

There is strictly no error message or anything indicating that something bad happened except in logs. The only way I had to know that happened was because the upload bandwidth was at 0kb/s and my stream died.

Both stream and local record stop silently, and I can't manage to restart both without restarting OBS entirely.

Code:
21:24:31.217: video settings reset:

21:24:31.217:     base resolution:   1920x1080
21:24:31.217:     output resolution: 1920x1080
21:24:31.217:     fps:               60/1
21:24:31.217:     format:            NV12
21:24:31.220: Settings changed (video)
21:24:31.220: ------------------------------------------------
21:24:32.936: [qsv encoder: 'streaming_h264'] settings:
21:24:32.936:     rate_control:   ICQ
21:24:32.936:     ICQ Quality:    20
21:24:32.936:     fps_num:        60
21:24:32.936:     fps_den:        1
21:24:32.936:     width:          1920
21:24:32.936:     height:         1080
21:24:32.936: [qsv encoder: 'streaming_h264'] debug info:
21:24:32.990:     impl:           D3D09
21:24:32.990:     surf:           SysMem
21:24:33.065:     m_nSurfNum:     15
21:24:33.081:     m_nTaskPool:    4
21:24:33.081:     major:          1
21:24:33.081:     minor:          17
21:24:33.081: ---------------------------------

Code:
22:17:22.443: ==== Streaming Start ===============================================

22:17:22.895: ==== Recording Start ===============================================
22:17:22.895: [ffmpeg muxer: 'adv_file_output'] Writing file 'D:/Local records/2016-05-30 22-17-22.mp4'...
22:17:33.651: [qsv encoder: 'streaming_h264'] encode failed
22:17:33.663: Error encoding with encoder 'streaming_h264'
22:17:33.663: Called profile end with mismatching name: start("do_encode"[000007FED26E7A78]) <-> end("receive_video"[000007FED26E7A88])
22:19:57.984: Output 'adv_stream': stopping
22:19:57.984: Output 'adv_stream': Total encoded frames: 9347
22:19:57.984: Output 'adv_stream': Total drawn frames: 9347
22:19:57.984: Output 'adv_stream': Number of skipped frames due to encoding lag: 111 (1.2%)
22:19:57.984: [rtmp stream: 'adv_stream'] User stopped the stream
22:19:57.984: ==== Streaming Stop ================================================
22:19:58.586: [ffmpeg muxer: 'adv_file_output'] Output of file 'D:/Local records/2016-05-30 22-17-22.mp4' stopped
22:19:58.586: Output 'adv_file_output': stopping
22:19:58.586: Output 'adv_file_output': Total encoded frames: 9342
22:19:58.586: Output 'adv_file_output': Total drawn frames: 9342
22:19:58.586: Output 'adv_file_output': Number of skipped frames due to encoding lag: 111 (1.2%)
22:19:58.586: ==== Recording Stop ================================================
Code:
21:24:33.333: ==== Streaming Start ===============================================
21:24:33.700: ==== Recording Start ===============================================
21:24:33.700: [ffmpeg muxer: 'adv_file_output'] Writing file 'D:/Local records/2016-05-30 21-24-33.mp4'...
22:14:48.402: [qsv encoder: 'streaming_h264'] encode failed
22:14:48.427: Error encoding with encoder 'streaming_h264'
22:14:48.427: Called profile end with mismatching name: start("do_encode"[000007FED27C7A78]) <-> end("receive_video"[000007FED27C7A88])
22:16:59.728: Output 'adv_stream': stopping
22:16:59.728: Output 'adv_stream': Total encoded frames: 188797
22:16:59.728: Output 'adv_stream': Total drawn frames: 188797
22:16:59.728: Output 'adv_stream': Number of skipped frames due to encoding lag: 116 (0.1%)
22:16:59.728: Output 'adv_stream': Number of lagged frames due to rendering lag/stalls: 131 (0.1%)
22:16:59.728: [rtmp stream: 'adv_stream'] User stopped the stream
22:16:59.728: ==== Streaming Stop ================================================
22:17:00.321: [ffmpeg muxer: 'adv_file_output'] Output of file 'D:/Local records/2016-05-30 21-24-33.mp4' stopped
22:17:00.321: Output 'adv_file_output': stopping
22:17:00.321: Output 'adv_file_output': Total encoded frames: 188796
22:17:00.321: Output 'adv_file_output': Total drawn frames: 188796
22:17:00.321: Output 'adv_file_output': Number of skipped frames due to encoding lag: 116 (0.1%)
22:17:00.321: Output 'adv_file_output': Number of lagged frames due to rendering lag/stalls: 131 (0.1%)
22:17:00.321: ==== Recording Stop ================================================

Full logs:
https://gist.github.com/anonymous/101627a0b341042fab98f03fbcdc8b8d
https://gist.github.com/anonymous/5e4a4de3621537cae096984dbf65e297

EDIT:

Additional informations:
I haven't yet tried if the 32bit version has the same problem. I'll check that.
I also haven't tried to use an older version of OBS Studio. I'll take time to check that too and update this post.
Last thing, OBS Classic worked perfectly with QSV on this exact PC with pretty much the same settings (QSV with ICQ settings)
 

c3r1c3

Member
Have you updated your GPU drivers to the latest available? (Grab at least the February drivers of this year). Earlier Intel GPU drivers had a good amount of crashing issues with the qsv process, so that's the first thing I would do.
 

Incalex

New Member
I feel ashamed that it wasn't the FIRST thing I check. My drivers were a bit old apparently (before 2016?)
I'll put that problem as solved for the moment, and retry with latests drivers.
Thanks for your help and for the really fast answer :)

EDIT: Not solved.
 
Last edited:

R1CH

Forum Admin
Developer
Try upgrading to Windows 10 if possible, QSV on Win 7 doesn't have the greatest driver support.
 

Incalex

New Member
The major reason on why I'm sticking on Windows 7 is because you can disable Aero, and run windowed/borderless games without having a vsync layer (I don't like vsync). DWM/Aero/Desktop Composition adds a Triple Buffer VSync on every window.
It's also true that it'll make desktop composition use GPU instead of CPU which is better too, but vsync means input lag (even a really really small one).

Besides that point, I'm wondering if it's purely a driver problem or not, as OBS Classic worked flawlessly for hours on QSV (and with the old and apparently buggy driver),but I'm not experienced enough to tell if that's right.

The major reason why I wanted to switch on OBS Studio is it works way better at capturing Final Fantasy: XIV (DX11) in 1080p60fps (I'm getting ~5% duplicated frames on OBS Classic, OBS Studio produced way smoother videos, and for a lower performance cost)

EDIT:
I plan to do more tests with different settings (different Async Depth, different encoding method thank ICQ (I'll test CQP as that would also do the job like ICQ)), all of that while staying on the latest version of OBS Studio.
I'll update again this post with more results.
 
Last edited:

Incalex

New Member
There you go, the settings window: http://i.imgur.com/4xKIkSq.png

I forgot to add one detail:
QSV worked perfectly on OBS Classic if I used the modified version of QSVHelper.exe available here: https://obsproject.com/forum/thread...killed-encode-failed.19230/page-3#post-161984 (link for files on the post right after the one I linked)

I'm wondering if it isn't the exact same problem but on OBS Studio (I checked a bit OBS Studio's QSV code, but I can't tell anything yet as I haven't tried anything. I'll probably compile it with more debug logs to check what exactly happens)
 

Suslik V

Active Member
Set FPS to 30 and use it (Settings>Video). Usually, same errors rise when HW codec expect values in range and your input produce out of range (resolution, profile, color space, frame rate and other restrictions).
 

Incalex

New Member
My goal is to do high quality local records at 60FPS and 1080P. Losing the 60FPS would be "really" annoying. The major performance gain on going on OBS Studio instead of OBS Classic was exactly that "1080p60fps" with specificly FF:XIV.

Still, I'm going to test if lowering the framerate to 30fps fixes anything (but I'm far from believing it)
 

Incalex

New Member
So, I wanted to try to integrate Shinck's QSVHelper.exe patch (see https://obsproject.com/forum/thread...killed-encode-failed.19230/page-3#post-161984) on the OBS Studio's QSV Encoder.

I did a really ugly implementation of his code on the obs-qsv library, and so far... it works, and perfectly.
Video and streaming worked flawlessly on 1080p60fps for more than 3hours.

Still, it's a really ugly and maybe buggy implementation, as restarting the encoder (streaming, stopping and restarting it) makes OBS crash (I guess I forgot to deallocate few things), but that solve the problem.

As far as I understood obs-sqv's code, it was a really specific problem. Thoses QSV issues should only happen on Win7 because of the lack of full DX11.1 support. So I don't think it was a Win7 Intel HD Graphics Driver problem, but the specific DX9 QSV implementation that had a problem.

I can't even say that Shinck' solution is the best or most efficient. But so far, it works...

I could post a patch if anyone's interessed, but that's a really dirty patch of the obs-qsv lib. I'm not even sure if it memory leaks or not.
 

Incalex

New Member
The modifications I applied are available on this patch:
https://gist.github.com/anonymous/6cd7589dddb5296599b19188cc4c521d

1/ It is a really ugly and dirty way of implementing it
2/ Most of code is purely copy pasted from Shinck's QSVHelper.exe patch
3/ OBS will crash if you restart the encoder
4/ You'd better wait for a real dev to properly implement this in a stable release
5/ For building, d3d9.lib and dxva2.lib are 2 additional required libraries
 

r1me

New Member
Is there any chance to post modified binaries with this patch, or can someone else apply it and rebuild OBS for us - aka Windows 7 fanboys ? ;-)
 

Harold

Active Member
The major reason on why I'm sticking on Windows 7 is because you can disable Aero, and run windowed/borderless games without having a vsync layer (I don't like vsync). DWM/Aero/Desktop Composition adds a Triple Buffer VSync on every window.
And yet you don't need to disable aero for that on windows 10.

Also, if you're using game capture, disabling aero actually reduces overall performance when using OBS.
 

c3r1c3

Member
incalex, if you're still around submit that as a pull request to OBS and maybe one of the devs will take it, clean it up and integrate it.
 

Incalex

New Member
And yet you don't need to disable aero for that on windows 10.

Also, if you're using game capture, disabling aero actually reduces overall performance when using OBS.
Disabling aero doesn't reduce "game capture" performance but "window capture" performance as it makes windows calculated by GPU because it's rendered with DirectX. Without Aero, CPU renders windows, which is considered less performant.
But, Aero/DirectX puts a layer of VSync that I really don't want on my windowed/borderless games. So either I have to play exclusive fullscreen, or I have to disable Aero.
Since I like being able to switch windows rapidly (useful in MMOs), I prefer the non-aero win7 way.
Also, if anyone's interessed in my qsv patch, and dlls for OBS Studio: https://obsproject.com/forum/threads/qsv-encoder-on-windows-7.49475/#post-245852
 
Top