OBS branch with AMD VCE support.

Discussion in 'Feedback and Suggestions' started by jackun, May 2, 2014.

  1. jackun

    Developer

    Github repo for the branch.

    I've implemented some support for AMD VCE. Probably all kinds of broken and memory leaky, but atleast something to build on :P So...test it and break it.

    There are currently 2 3 implementations: with the older OpenVideo encode API (OVE) and with AMD Media SDK (Windows' Media Foundation transform aka MFT). Now also with AMD's AMF(ramework).

    For older MFT-based encoder: If encoder freezes, encoding quality setting is too high for given fps/resolution. Lower video fps or enable custom settings and set QualityVsSpeed at or lower than 50. Also 60 fps capture has some weird memory usage issues.

    Current formula for fixed quantizer parameter values is 40 - (quality * 5) / 2.

    OVE version can use OpenCL for colorspace conversion (YUV444 to NV12), but it is currently done before passing the frame to be encoded. It adds to encode time and can make OBS drop frames so it is better suited for 30..50 fps recording and low performance CPUs, for now.

    For clarification:
    • AMF: OpenCL interop assumes that the video adapter OBS uses also has VCE support. There's a secret AdapterID setting that may or may not work for selecting another adapter.
    • D3D & OpenCL interop doesn't have anything to do with games, only with OBS as it uses D3D10 to do its magic. Ticking make OBS use CPU for NV12 conversion instead and on Win8+ DX11 engine will use NV12 textures. Dx9 and Win7 resort to using host memory for NV12 buffers.
    • Device TopoID is the 'physical' location on motherboard, not device vendor ID etc. as you can have more than 1 device with same ID. Check log (window). It only affects OVE because if I'm not missing something, you can't specify device for AMF (yet). But it could be using the device that AMF context got init'ed with. If that's the case then it uses the selected device from Video > Video Adapter.
    GPU heavy games can cause frame freezing. You can try disabling D3D10 interop (and with AMF, select "Host" engine type) so that encoder preparation work is done on CPU instead. But then there is the issue of copying stuff into GPU VRAM so it might not give any performance boost.

    Supported hardware from AMD's blog.

    Binaries / change log

    You may also need to install MS VC++ 2013 runtimes. (Choose by OBS' bitness, not your operating system's.)

    Latest Binaries: No need to install, just grab a decompressor (7-zip or WinRAR), unpack and run it.
    2015-06-18: [32bit] [64bit] Update to git head and merge Kobata's h264 profile level and no resolution checking patch.

    Archived binaries:

    2015-03-17 [32bit] [64bit]: Update to v0.65+.
    2015-02-08 [32bit] [64bit]: Update to release Media SDK 1.1. AMF: rework getting initial SPS/PPS nals.
    2015-02-17: device selection see here.
    2015-02-01 [32bit] [64bit]: Update to v0.64. Updated: fix underrun of DX11 buffers.
    2015-01-07 [32bit] [64bit]: AMF profile level to 4.1. Fix mid-stream SPS/PPS causing Flash to display green frames.
    2014-12-29 [32 bit] [64 bit]: Separate QP controls for Constrained QP mode. "Discard filler" option when doing local recording to try to fix blurry blocks in static scenes quirk with CBR (enable CBR padding too!)
    2014-12-26 [32bit] [64bit]: Rate control methods are now selectable.
    2014-11-23 [32bit] [64bit]: Test with threading (AMF only for now).
    2014-11-16 N/A. Random reference counting error causing crashing.
    2014-11-04 [32bit] [64bit]: Without (most) profiling code. Seemed to help reduce some encoder lag.
    2014-10-28 [32bit] [64bit]: Added MinQP/MaxQP setting.
    2014-10-25 [32bit] [64bit]: v0.637b+ Optional D3D10+OpenCL interoperability.
    2014-09-10 [32bit] [64bit]: Using host memory for surfaces (and looks like dx9 interop). MFT is (temporarily?) replaced with AMF (AMD's media framework).

    Some posts with random info
    [1] [2] [3 older tests by Fawkes]
    Last edited: Jun 18, 2015
    Performer, Ilyas, Kadano and 7 others like this.
  2. shaNker Member

    Thank you again, I replied to you in my original thread!!!! You can look there too but since you made a dedicated thread I'll post what I've encountered here too.

    First off CPU usage is minimal, so that's awesome! Thank you! I feel the same as when I am recording with Bandicam I can't notice any lag. However two issues I've encountered are a very thin green line at the bottom of my captures, and the second is severe frame tearing. This is the first time I've ever encountered this issue. When I just use OBS or Bandicam I don't get this issue. Here is a video to show you.

    https://app.box.com/s/ib1ohaffdkj4ynja2j6o
  3. dodgepong Meat Popsicle

    Admin

    Jackun, were you wanting this to get merged in? I assume you don't want to keep it as a fork...

    It would probably be good for you to join the #obs-dev IRC channel to be in communication with the other devs. I think there were a couple other people already working on VCE, though I can't remember.
  4. jackun

    Developer

    Might be that input buffers are updated while encoder is still doing its thing.
    About green line, what resolution are you recording at? VCE (like most h264 encoders probably) needs the resolution to be multiples of 16 or so. Video bitstream (or is in container?) has the original input resolution and player should crop to that (if i'm not mistaken). But we take anything and just pad it out so where there is zero bytes it shows up green in YUV colorspace.

    There is an issue with 64bit build. Have to check if it is a issue with 14.4 beta drivers, but for some reason clCreateContext crashes with invalid memory access with device id from openvideo.dll. Then again, my OpenEncodeVFW works with 64bit virtualdub (device id address is lower though)
    Last edited: May 3, 2014
  5. XeiZ Well-Known Member

    So far it has been running smooth, i take that CBR isnt possible/you didnt bother with it yet and bitrate is also locked at 2000000?
  6. jackun

    Developer

    CBR should be supported (as long as i didn't forget to set any settings :P)
    Here, so CBR -> CBR, CRF -> Fixed QP and nothing sets VBR.

    Hm, OBS is pretty conservative with requesting key frames? All is just bunch of P frames so seeking is so "fast" heh.
  7. XeiZ Well-Known Member

    mh i was just asking because with a bitrate set to 1700 (just testing around) it spiked up to 47000kbps with and without cbr checked, the logfile also reports that the bitrate is set to 2000000.
  8. jackun

    Developer

    Ok, try this. Look in log for "Rate control method". 0 - fixed QP, 3 - CBR, 4 - VBR.
  9. Jack0r The Helping Squad

    Moderator

    that dll crashes my OBS when I try to get into the encoding settings :)
    edit: hmm, now it crashes everytime...
    if you want the crashdump, message me, guess I would have to reboot to check if that fixes it for the moment. did a short test yesterday and one earlier today without problems.
  10. XeiZ Well-Known Member

    I dont see anything regarding that in the logfile.
    http://pastebin.com/BY3NCbHQ
  11. jackun

    Developer

  12. XeiZ Well-Known Member

    Okay that changed a bit. :)
    Rate control method is now 3 and it kinda sticks to 2000kbps which i set it to, on no/low motion it still drops to 100kbps and on sudden changes it sometimes shoots up to 10000kbps+, seems really unstable in that regard, pretty much vbr or x264s cbr without padding enabled.
  13. jackun

    Developer

    Well, there's a peak rate variable. New version sets it to the bitrate.
    It also has 8 input buffers now and for some reason first frame's top half is green.
    Getting any duplicate frames? I get some with BF4 randomly.

    E: Quick test at 1500Kbps, ffdshow OSD 'input bitrate' shows ~1500 - 1520Kbps
    Last edited: May 3, 2014
  14. XeiZ Well-Known Member

    yup with this one it sticks to the bitrate way more stable and similar to "normal" x264 cbr.

    edit: whoops didnt see the question, 0.14% duplicated frames, though i dont have any current game that eats cpu/gpu alive to test with.
    Last edited: May 3, 2014
  15. shaNker Member

    I'm capturing at 1920 X 1080, standard HD. I'm using the 14.4 drivers but they are release drivers not beta but who knows still could be a driver issue? I have an R9 200x, or is it 220x? I'm using the 32bit version but running on Windows 7 64bit OS don't know if that should be related to the issue.
  16. XeiZ Well-Known Member

    does the same happen if you downscale to 720p? Jack0r told me in the irc he also had issues with it and he tested 1080p.

    Also, i wonder what causes this but currently its not useable for twitch as twitch doesnt accept the cbr behaviour, my guess is since the bitrate starts out really low and climbs up slowly it thinks its vbr and thus gives you only the acceptable flag. Something that also should be sorted out i guess since people will ask about that.
  17. jackun

    Developer

    shaNker if you mean tearing then download it again. Should have less now (ok, now >_< ). Bandicam has AMD APP support, right? Does Bandicam's CBR keep its bitrate somewhat stable?

    VCE seems to ignore some settings like peak bitrate (resets to bitrate) and VBV buffer size sits at 10Mbps. CBR doesn't want to hard limit to bitrate.
    Also my R9 290 takes mysterious control method 5. Maybe Media SDK 1.1 has more info.
    Last edited: May 4, 2014
  18. Jack0r The Helping Squad

    Moderator

    Hmm, a reboot did not help either, no matter what, it crashes when I try to check the Encoding Settings. Tried resetting OBS to default settings, etc.

    This crash appears to have occured in the 'd:\obs-vce\obsvce.dll' module.

    **** UNHANDLED EXCEPTION: c0000005
    Fault address: 683947A7 (d:\obs-vce\obsvce.dll)
    OBS version: Open Broadcaster Software v0.622b
    Windows version: 6.2 (Build 9200)
    CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz

    Crashing thread stack trace:
    Stack EIP Arg0 Arg1 Arg2 Arg3 Address
    0061DA98 683947A7 0061DC2C 273C1382 0085FDC0 756B980C obsvce.dll!0x683947a7
    0061DAAC 68391EA2 0085FDC0 756B980C 00000001 0008085A obsvce.dll!0x68391ea2
    0061DC58 68396446 0061DD2C 00BAF7BB 00C685A0 0008085A obsvce.dll!0x68396446
    0061DC74 683962D7 00C685A0 0008085A 0085FDC0 00000000 obsvce.dll!0x683962d7
    0061DC7C 00BAF7BB 00000110 00000000 0085FDC0 00000000 obs.exe!0xbaf7bb
    0061DD34 68735DFE 0008085A 00000110 00000000 0085FDC0 obsapi.dll!0x68735dfe
    0061DD50 75557834 68735DC0 0008085A 00000110 00000000 user32.dll!0x75557834
    0061DD7C 7556D4B5 0008085A 00000110 00000000 0085FDC0 user32.dll!0x7556d4b5
    0061DE00 7556D1EC 00F39810 00000000 00000110 00000000 user32.dll!0x7556d1ec
    0061DE5C 7556D3FA 0008085A 00000110 00000000 0085FDC0 user32.dll!0x7556d3fa
    0061DE7C 75557834 7783B860 0008085A 00000110 00000000 user32.dll!0x75557834
    0061DEA8 75557A9A 7783B860 00000000 00000110 00000000 user32.dll!0x75557a9a
    0061DF38 75557BED 00F39810 00000000 00000110 00000000 user32.dll!0x75557bed
    0061DF98 75557D81 0061DFE0 00000000 0061E1F4 7784F2A0 user32.dll!0x75557d81
    0061DFD0 7784F342 00F39810 00000000 0085FDC0 00000000 ntdll.dll!0x7784f342
    0061E068 7556DD30 00B50000 00C7F5B8 0000080C 0001084A user32.dll!0x7556dd30
    0061E16C 7556DC77 00B50000 00C7F5B8 0001084A 68735DC0 user32.dll!0x7556dc77
    0061E190 7556F388 00B50000 00000073 0001084A 68735DC0 user32.dll!0x7556f388
    0061E1BC 68733493 0001084A 68735DC0 0085FDC0 0001084A obsapi.dll!0x68733493
    0061E20C 68733C62 00B50000 00000073 0001084A 68735DC0 obsapi.dll!0x68733c62
    0061E23C 00BAEB1E 0001084A 00000001 00000000 00000001 obs.exe!0xbaeb1e
    0061E25C 00BABD10 0001084A 00000111 000103EE 0001084C obs.exe!0xbabd10
    0061E4D8 75557834 00BABA80 0001084A 00000111 000103EE user32.dll!0x75557834
    0061E504 7556D375 0001084A 00000111 000103EE 0001084C user32.dll!0x7556d375
    0061E588 7556D1EC 00F36B20 00000000 00000111 000103EE user32.dll!0x7556d1ec
    0061E5E4 7556D3FA 0001084A 00000111 000103EE 0001084C user32.dll!0x7556d3fa
    0061E604 75557834 7556D3D5 0001084A 00000111 000103EE user32.dll!0x75557834
    0061E630 75557A9A 7556D3D5 00000000 00000111 000103EE user32.dll!0x75557a9a
    0061E6C0 7555CE71 7556D3D5 0001084A 00000111 000103EE user32.dll!0x7555ce71
    0061E6F8 05A681A3 0001084A 00000111 000103EE 0001084C ammemb.dll!0x5a681a3
    0061E784 75557834 05F90FB0 0001084A 00000111 000103EE user32.dll!0x75557834
    0061E7B0 75557A9A 05F90FB0 00000000 00000111 000103EE user32.dll!0x75557a9a
    0061E840 75557BED 00F36B20 00000000 00000111 000103EE user32.dll!0x75557bed
    0061E8A0 75557D81 0061E8E8 00000000 0061EB64 7784F2A0 user32.dll!0x75557d81
    0061E8D8 7784F342 00F36B20 00000000 0001084C 00000000 ntdll.dll!0x7784f342
    0061E970 7555D400 0001084A 00000111 000103EE 0001084C user32.dll!0x7555d400
    0061E9A4 74F59204 00000027 0000001A 001A0027 74F60602 comctl32.dll!0x74f59204
    0061EA20 74F59805 0001084C 00000202 00000000 001A0027 comctl32.dll!0x74f59805
    0061EAC0 75557834 74F60602 0001084C 00000202 00000000 user32.dll!0x75557834
    0061EAEC 75557A9A 74F60602 00000000 00000202 00000000 user32.dll!0x75557a9a
    0061EB7C 7555988E 00040780 00000000 0001084A 00000000 user32.dll!0x7555988e
    0061EBE8 75572626 0001084A 0061EC2C 00000001 00040780 user32.dll!0x75572626
    0061EC18 755726A8 00000001 00000001 00B50000 FFFFFFFF user32.dll!0x755726a8
    0061EC60 75572F93 00040780 00BABA80 00000000 00000001 user32.dll!0x75572f93
    0061EC90 75573036 00B50000 00C7EA30 00040780 00BABA80 user32.dll!0x75573036
    0061ECA8 755A545A 00B50000 00000065 00040780 00BABA80 user32.dll!0x755a545a
    0061ECCC 68733676 00040780 00BABA80 00000000 00001388 obsapi.dll!0x68733676
    0061ED1C 68733B72 00B50000 00000065 00040780 00BABA80 obsapi.dll!0x68733b72
    0061ED4C 00BC26DE 00040780 00000111 00001388 00010826 obs.exe!0xbc26de
    0061EE4C 75557834 00BC19D0 00040780 00000111 00001388 user32.dll!0x75557834
    0061EE78 75557A9A 00BC19D0 00000000 00000111 00001388 user32.dll!0x75557a9a
    0061EF08 7555CE71 00BC19D0 00040780 00000111 00001388 user32.dll!0x7555ce71
    0061EF40 05A681A3 00040780 00000111 00001388 00010826 ammemb.dll!0x5a681a3
    0061EFCC 75557834 05F90FCC 00040780 00000111 00001388 user32.dll!0x75557834
    0061EFF8 75557A9A 05F90FCC 00000000 00000111 00001388 user32.dll!0x75557a9a
    0061F088 75557BED 00ECC370 00000000 00000111 00001388 user32.dll!0x75557bed
    0061F0E8 75557D81 0061F130 00000000 0061F354 7784F2A0 user32.dll!0x75557d81
    0061F120 7784F342 00ECC370 00000000 00010826 00000000 ntdll.dll!0x7784f342
    0061F1B8 7555D400 00040780 00000111 00001388 00010826 user32.dll!0x7555d400
    0061F1E8 74F5A2E2 000C004B 74F41F31 00000000 0061F218 comctl32.dll!0x74f5a2e2
    0061F220 74F5A314 00010826 00000202 00000000 000C004B comctl32.dll!0x74f5a314
    0061F2B0 75557834 74F41F31 00010826 00000202 00000000 user32.dll!0x75557834
    0061F2DC 75557A9A 74F41F31 00000000 00000202 00000000 user32.dll!0x75557a9a
    0061F36C 7555988E 755598FB 7555955E 00220205 0061F49C user32.dll!0x7555988e
    0061F3D8 75572626 00040780 0061F49C 00000000 00000001 user32.dll!0x75572626
    0061F408 00B96000 00B50000 00000000 008A29ED 00000001 obs.exe!0xb96000
    0061F8D4 00BDEA0A FF66B000 0061F968 7785A8CB FF66B000 obs.exe!0xbdea0a
    0061F920 756B919F FF66B000 1C34D10D 00000000 00000000 kernel32.dll!0x756b919f
    0061F92C 7785A8CB FFFFFFFF 7784F69B 00000000 00000000 ntdll.dll!0x7785a8cb
    0061F970 7785A8A1 00BDE903 FF66B000 00000000 00000000 ntdll.dll!0x7785a8a1

    A minidump was saved to D:\OBS-vce\crashDumps\OBSCrashDump2014-05-04_3.dmp.
    Please include this file when posting a crash report.

    List of loaded modules:
    Base Address Module
    00B50000-00CA8000 D:\OBS-vce\OBS.exe
    77810000-77978000 C:\Windows\SYSTEM32\ntdll.dll
    756A0000-757E0000 C:\Windows\SYSTEM32\KERNEL32.DLL
    75AF0000-75BBF000 C:\Windows\SYSTEM32\KERNELBASE.dll
    74B00000-74B09000 C:\Windows\SYSTEM32\AVRT.dll
    73AC0000-73AD8000 C:\Windows\SYSTEM32\dwmapi.dll
    73A50000-73AB2000 C:\Windows\SYSTEM32\dxgi.dll
    689B0000-689D9000 C:\Windows\SYSTEM32\d3d10_1.dll
    68930000-689A4000 C:\Windows\SYSTEM32\d3dx10_43.dll
    75AA0000-75AED000 C:\Windows\SYSTEM32\WS2_32.dll
    74AE0000-74AFE000 C:\Windows\SYSTEM32\IPHLPAPI.DLL
    73760000-73780000 C:\Windows\SYSTEM32\WINMM.dll
    68720000-68923000 D:\OBS-vce\OBSApi.dll
    75F40000-770ED000 C:\Windows\SYSTEM32\SHELL32.dll
    73420000-7356D000 C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.9600.17056_none_dadc5d1c5bc8ab48\gdiplus.dll
    72580000-72614000 C:\Windows\SYSTEM32\WINHTTP.dll
    68510000-6871C000 D:\OBS-vce\libx264-140.dll
    746B0000-7478B000 C:\Windows\SYSTEM32\UxTheme.dll
    68500000-68506000 C:\Windows\SYSTEM32\XINPUT9_1_0.dll
    75550000-7569F000 C:\Windows\SYSTEM32\USER32.dll
    77630000-77738000 C:\Windows\SYSTEM32\GDI32.dll
    75990000-75A08000 C:\Windows\SYSTEM32\ADVAPI32.dll
    77520000-7762C000 C:\Windows\SYSTEM32\ole32.dll
    75510000-7554E000 C:\Windows\SYSTEM32\sechost.dll
    75450000-7550E000 C:\Windows\SYSTEM32\msvcrt.dll
    75260000-753AE000 C:\Windows\SYSTEM32\combase.dll
    684A0000-684F1000 C:\Windows\SYSTEM32\d3d10_1core.dll
    738A0000-73A4F000 C:\Windows\SYSTEM32\d3d11.dll
    75D40000-75D47000 C:\Windows\SYSTEM32\NSI.dll
    758C0000-75971000 C:\Windows\SYSTEM32\RPCRT4.dll
    744E0000-744E8000 C:\Windows\SYSTEM32\WINNSI.DLL
    73740000-73760000 C:\Windows\SYSTEM32\WINMMBASE.dll
    753B0000-753B6000 C:\Windows\SYSTEM32\PSAPI.DLL
    757E0000-75821000 C:\Windows\SYSTEM32\SHLWAPI.dll
    75240000-7525D000 C:\Windows\SYSTEM32\SspiCli.dll
    77290000-772CA000 C:\Windows\SYSTEM32\cfgmgr32.dll
    73CE0000-73CFF000 C:\Windows\SYSTEM32\DEVOBJ.dll
    75230000-75239000 C:\Windows\SYSTEM32\CRYPTBASE.dll
    751D0000-75223000 C:\Windows\SYSTEM32\bcryptPrimitives.dll
    77140000-77165000 C:\Windows\system32\IMM32.DLL
    772D0000-773C7000 C:\Windows\SYSTEM32\MSCTF.dll
    74CB0000-74D26000 C:\Windows\SYSTEM32\shcore.dll
    75110000-75119000 C:\Windows\SYSTEM32\kernel.appcore.dll
    74F10000-750F6000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9600.17031_none_a9efdb8b01377ea7\Comctl32.dll
    05A40000-05AD6000 C:\Users\Jack\AppData\Local\Temp\ammemb.dll
    771E0000-77267000 C:\Windows\SYSTEM32\oleaut32.dll
    75100000-75108000 C:\Windows\SYSTEM32\version.dll
    74F00000-74F06000 C:\Windows\SYSTEM32\msimg32.dll
    753D0000-7544D000 C:\Windows\SYSTEM32\clbcatq.dll
    71730000-7177A000 C:\Windows\System32\MMDevApi.dll
    68460000-68497000 D:\OBS-vce\plugins\DShowPlugin.dll
    68430000-68458000 D:\OBS-vce\plugins\GraphicsCapture.dll
    68400000-6842A000 D:\OBS-vce\plugins\NoiseGate.dll
    683E0000-683FD000 D:\OBS-vce\plugins\PSVPlugin.dll
    72640000-72652000 C:\Windows\SYSTEM32\dhcpcsvc6.DLL
    732F0000-73303000 C:\Windows\SYSTEM32\dhcpcsvc.DLL
    73F50000-73F95000 C:\Windows\system32\mswsock.dll
    683B0000-683DC000 D:\OBS-vce\ObsNvenc.dll
    68390000-683A1000 D:\OBS-vce\ObsVCE.dll
    68370000-68383000 C:\Windows\SYSTEM32\OpenCL.dll
    682F0000-68361000 C:\Windows\SYSTEM32\MSVCP120.dll
    68200000-682EE000 C:\Windows\SYSTEM32\MSVCR120.dll
    681E0000-681F9000 C:\Windows\SYSTEM32\OpenVideo.dll
    6DA90000-6DBD8000 C:\Windows\SYSTEM32\DBGHELP.DLL
  19. jackun

    Developer

    Get the newer version and upload the dump file. I take it you have supported hardware? :D

    Tearing... brainfarting with the RequestBuffers() part. OBS keeps passing old "deallocated" buffer back. Current version just remaps now, but seems to have less tearing (but stutters more?)
  20. Jack0r The Helping Squad

    Moderator

    Ah, yeah that works, I missed that you updated it in the first post. Now the recording also had no tearing or strange images, but I noticed something else:
    using 1920x1080 at 60fps and a recorded video for input
    CBR active, 5000 bitrate, everything works
    VBR active, 5000 bitrate, everything works
    CBR/VBR, 50000 bitrate, takes too long to encode no matter what I try

Share This Page