-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AV1 Video Decode with Media Source does not use HW Decode on AMD Windows #10213
Comments
This is most likely expected. Media source uses ffmpeg for playback, so we'd need to ship a version that supports HW decode (if one even exists at the moment). |
d3d11va and dxva2 (H.264, MPEG-2, VC-1, WMV 3,VP9, AV1, HEVC) in ffmpeg both cover the HW decode for AV1 and should be available already. One of them is what VP9 HW decode in obs ffmpeg already uses. I will play around with standalone ffmpeg for Windows and see if it can be made to work or not. |
Tested both D3D11VA and DXVA2 on standalone ffmpeg for VP9 and AV1. Using the BtbN builds
On VP9:
and it fell back to using software decoding d3d11va worked On AV1:
d3d11va worked
edit:specifying So it looks like AMD did not implement AV1 decode in their DX9 driver which makes sense because it is probably rarely used compared to the DX11 driver. So this appears to be a purely OBS issue @Fenrirthviti since I have confirmed that obs-studio/deps/media-playback/media-playback/decode.c Lines 23 to 28 in b45a732
hwaccel=d3d11va in custom ffmpeg options without any affect for both VP9 and AV1, so it seems this option is filtered out or overridden by the "Use hardware decoding when available" option.
|
I don't know offhand if we ship with d3d11va enabled on Windows or not. Could be as simple as enabling in the build. Tagging @RytoEX as he's more familiar with our ffmpeg build opts. |
got the build info from checking the strings in the OBS libavcodec.dll
which matches up with what the ffmpeg buildscript shows https://github.com/obsproject/obs-deps/blob/e1d4ddd710dbcc08407ff4c5c6267372b6bb0c83/deps.ffmpeg/99-ffmpeg.zsh which is commit version of obs-deps used in OBS 30.0.2 So it isn't explicitly enabled, though I don't think it needs to be. After all, VP9 is already using HW decode and the only HW decoder available for it in ffmpeg is d3d11va, so you would think it must be available. |
OBS Studio 30.0.2 uses FFmpeg n6.0 with some commits backported. Please test with that to see if
You shouldn't have to specify anything. OBS will test each enum value in order until one works. If none of them work, then you do not get hardware accelerated decode. |
also confirmed that |
no need. see the above comment. The issue still exists on OBS 30.1-beta1 which uses ffmpeg 6.1.1 https://github.com/obsproject/obs-deps/blob/4202b500fdd849eaf50272e4856880b0b8218350/deps.ffmpeg/99-ffmpeg.zsh#L5 |
ignore previous message that I already deleted (forgot to put @RytoEX I should have thought to test the OBS deps directly. FFmpeg binary is built, just not shipped with OBS.
![]() So it seems to not be FFmpeg itself but how OBS calls it is somehow flawed still. |
I dug into this a little bit. The short answer so far is that Checking the debug log output of ffmpeg.exe, it looks like FFmpeg changes the decoder from the specific codec (e.g., libaom-av1) to a generic one:
As far as I can tell, ffmpeg.exe (the implementation in ffmpeg_demux.c) is different and more failsafe than their example implementation in hw_decode.c, which has no such fallbacks and is closer to our implementation. I suspect if you tried to compile and use their hw_decode example, it would also fail. |
I think your suspicions are probably right. The example implementation hasn't been touched seriously in over 3 years. It's probably safe to say nobody tested against it. I could try to compile ffmpeg on windows but that's going to take a lot of setup on my end... Not really prepared for that (I'm more of a Linux person myself). Might be worth pinging elenril who authored the movement of selecting hwaccel into ffmpeg_demux.c and also the original implementation in ffmpeg_opt.c before the move. They might have input to say their either the example code should be updated to include those changes or I think my question now is, why is
libaom-av1 as the codec as well when that function calls avcodec_find_decoder(id)
|
The tricky thing about ffmpeg.exe is that it has failsafes/fallbacks like this to try to resolve to a known working condition.
Our deps build scripts can now produce FFmpeg builds on Windows. I may also get around to trying to build the example eventually, but I have other tasks that are more likely to consume my time at the moment.
Personally, I wouldn't know where to begin there.
Yes,
Similarly, |
Small context for you why |
pinging relevant authors from https://github.com/FFmpeg/FFmpeg/blob/master/fftools/ffmpeg_demux.c and https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c the issue we are having is that decode of AV1 video ends up with I believe that the last commit from @xhaihao (FFmpeg/FFmpeg@ad67ea9) actually fixes this issue in ffmpeg since the commit message description seems to explain the issue identically
The example code (https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c) it seems is not updated to include that change. |
While I appreciate the enthusiasm and the attempt to get visibility on this, our repo is probably not the best place to discuss issues with FFmpeg examples. For issues with their examples, someone should probably file a bug on FFmpeg's Trac or bring it up in their IRC or on their mailing list. For the problem here, we probably need to implement something similar to what was done in |
Operating System Info
Windows 11
Other OS
No response
OBS Studio Version
30.0.2 and 30.1-beta1
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/LPk6Mr1icydav9OL
OBS Studio Crash Log URL
No response
Expected Behavior
I expect hardware decoding to be used on AMD AV1 when using the "Media Source"
Current Behavior
Software video decode on the CPU is used for AV1 when using the "Media Source"
Steps to Reproduce
Anything else we should know?
Tested the same file in Windows Media Player and Video Codec is used and CPU usage is very low (HW decode is used). So this is not an issue with the tested video files (I have tried AV1 video files all with the same result).
VP9 AMD HW accelerated decode works in "Media Source"
The text was updated successfully, but these errors were encountered: