win-mediafoundation: Introduce Media Foundation-based encoding support on WoA#11993
win-mediafoundation: Introduce Media Foundation-based encoding support on WoA#11993thirumalai-qcom wants to merge 5 commits intoobsproject:masterfrom
Conversation
55aa652 to
ea69f55
Compare
PatTheMav
left a comment
There was a problem hiding this comment.
I'm wary about just reintroducing the old code as-is, particularly as we have progressed to C++17 and expect modern C++ coding practices, including but not limited to:
- Use of anonymous namespaces instead of
staticfunctions is deprecated in C++ (static functions are only used for class methods in modern C++). - Use of
constexpras it's preferable over macros in almost all situations as they enable the compiler to optimise code better and sometimes resolve entire code paths at compile time - Abuse of macros instead of functions marked as
constexpr(see above) which makes the code harder to debug
Just merging this would mean re-importing the code smell as well and I just don't see someone else volunteering to "refactor" it after it's been merged again.
|
I tested this on my Snapdragon X laptop and it does work as expected. But Ideally this plugin should be either rewritten from the ground up, or replaced wholesale with just using the FFmpeg implemenation. At the very least, the AAC encoder could probably be removed. Of course since this is ancient it also doesn't support AV1 (which the X Elite chips do support). Aside from what Pat mentioned, the naming also conflicts with #10471 right now. |
ea69f55 to
109de95
Compare
|
Will this work with my older Surface Pro X (SQ2)? If it works I can help test it. |
13c8aac to
2aa95e6
Compare
@dd-han Thanks for offering to help. |
You are using the Media Foundation encoder via FFmpeg. That is not what is in this PR, and this PR has not been merged, so it is not in OBS Studio 31.1.0 Beta 1. Please use our forums or Discord for assistance. |
You need to pass additional flags to make hardware encoding work with the ffmpeg backend. |
2aa95e6 to
e066af7
Compare
e066af7 to
f7fd3aa
Compare
PatTheMav
left a comment
There was a problem hiding this comment.
Left a first round of reviews, will still have to look at the HEVC and H264 encoder implementations.
Except for the missing newline issues I haven't commented on every repeat issue, so things like functions marked inline in compilation units, opaque variable names, "magic" global variables, should be fixed throughout and not just were I first encountered them in review.
|
Couple more notes:
|
f7fd3aa to
b521f72
Compare
88a1a72 to
8ba0168
Compare
19a4f9f to
0db8d70
Compare
|
Tested 19a4f9f on my fork https://github.com/happyme531/obs-studio/actions/runs/19539489248 on my Snapdragon X Elite laptop. The H.264 and 265 encoders produce broken videos on CBR mode but works fine in VBR. AV1 endoder works fine.
|
Hi @happyme531, Thank you so much for testing our changes and sharing such detailed feedback—we really appreciate the time you took to validate this on your Snapdragon X Elite setup. Here’s what I observed during my tests with OBS Studio: 1080p input, output configured with CBR 2500 kbps → Output looks fine. Similarly, using FFmpeg: By default, it uses 1000 kbps, which results in pixelation. When I set the bitrate to 5000 kbps, the output looks proper. Could you confirm if you’re seeing the same behavior? |
Did more testing. The input is configured to 3440x1440p60 . CBR 2500k produced working video when selecting mp4, hybrid mp4, mov or flv format but produced completely broken video (black screen) with mkv(which is the default format). Weirdly FFmpeg is broken too with mediafondation encoder with mkv output, h264 and av1, cbr and vbr. libx264 works fine. |
RytoEX
left a comment
There was a problem hiding this comment.
Following up on the naming discussion, please use plugins/win-mediafoundation/encoder as the base plugin folder. This should resolve the naming/location feedback.
0db8d70 to
17ff468
Compare
|
Hi @RytoEX, |
17ff468 to
a702127
Compare
This commit re-introduces the base files required for Media Foundation Transform (MFT) support in the mediafoundation plugin, specifically targeting Windows on ARM devices with Qualcomm hardware. It includes core implementation files, language configuration file for localization, and the initial CMakeLists.txt for integration. Co-authored-by: Vignesh-qcom <vignelum@qti.qualcomm.com>
This commit introduces H264 encoder support using the Media Foundation Transform (MFT) interface, specifically targeting Windows on ARM (WoA) devices with Qualcomm hardware. It adds mf-h264.cpp and mf-h264-encoder.cpp/.hpp to implement the encoding logic. Co-authored-by: Vignesh-qcom <vignelum@qti.qualcomm.com>
This commit introduces HEVC encoder support using the Media Foundation Transform (MFT) interface, specifically targeting Windows on ARM (WoA) devices with Qualcomm hardware. It adds mf-hevc.cpp and mf-hevc-encoder.cpp/.hpp to implement the encoding logic. Co-authored-by: Vignesh-qcom <vignelum@qti.qualcomm.com>
This commit introduces AV1 encoder support using the Media Foundation Transform (MFT) interface, specifically targeting Windows on ARM (WoA) devices with Qualcomm hardware. It adds mf-av1.cpp and mf-av1-encoder.cpp/.hpp to implement the encoding logic. Co-authored-by: Vignesh-qcom <vignelum@qti.qualcomm.com>
This commit updates the CMakeLists.txt file in the plugins directory to incorporate the mediafoundation plugin into OBS build system. This ensures that Media Foundation-based encoding is available for Windows on ARM (WoA) devices, utilizing Qualcomm hardware for efficient video Encoding.
a702127 to
d1336b7
Compare
Hi @derrod, The PR has been rebased, the recommended DirectX texture input support for the encoder has been fully implemented, and the resulting CI build artifacts have been verified through testing. CC: @RytoEX and @PatTheMav |
I'll try to review and test it on my Snapdragon laptop it sometime this week. |
|
It seems have some problem on my Windows Dev Kit 2023 (Snapdragon 8cx Gen3). (Binary from https://github.com/obsproject/obs-studio/actions/runs/21711435452) I'm not sure is my configure has some error or driver has some issues? I would be very grateful if someone could offer some help. FFmpeg is working fine, so I think it might be some configuration issue? Failed with
|
For HEVC encoding, depending how it's enumerating the encoder, you may need the HEVC Video Extensions installed: 8cx Gen3 is the older generation Snapdragon. The 8cx should still support Media Foundation. The new Snapdragon X series mainly added support for AV1 hardware encoding. The 8cx Gen3 uses the Adreno 690. The X series use X1-45 or X1-85 and X2 will use X2-85 or X2-90. Here's a good overview of encoding capabilities of the Adreno GPU model (X1-85) in the current X series Snapdragon: I can't find anything enumerating the specifics of the 690. Gemini did provide these tips (unverified):
|
|
Yes, I know that part of HEVC, I installed the plugin for HEVC, FFmpeg is available to use the hardware encoder for H264/HEVC. Thank you for your answer. I am currently debugging h264_mf in Sunshine. The error reported by Sunshine (FFmpeg avcodec) is I think this part seems to have something to do with the driver difference. According to another Sunshine developer's description, he can use it normally on X1 GPU, so I'm a little confused because FFmpeg works. |
Hi @rbqvq, Thanks for testing the changes. |
|
Just providing some feedback. Using a Lenovo Yoga Slim 7x with Snapdragon Elite. Set recording video codec to Qualcomm AV1, MKV container and 10,000 bitrate. Default rate of 2,500 quality was too blurr/blocky. I checked task manager and for sure it was using my GPU. |
I add a source from Display Capture (2K 120fps) In addition, I will debug the specific error code via mftrace later. Thanks. |
| MF.H264.EncoderHWAMD="AMD Video Coding Engine H.264 Encoder (Media Foundation)" | ||
| MF.H264.EncoderHWIntel="Intel Quick Sync H.264 Encoder (Media Foundation)" | ||
| MF.H264.EncoderHWNVIDIA="NVIDIA NVENC H.264 Encoder (Media Foundation)" | ||
| MF.H264.EncoderHWQCOM="Qulcomm(R) Adreno(TM) H.264 (AVC) Encoder" |
There was a problem hiding this comment.
Qualcomm is misspelled as "Qulcomm" in multiple locations
|
I've re-tested now on my X1 Elite laptop, here's some notes:
Sometimes performance seems a bit iffy and there seem to be dropped frames, but I need to do more testing. It seems that 60 FPS was fine but 30 FPS had issues, which is unexpected. AV1 example with CBR @ 6 Mbps:
|
|
I've tested record feature, it also a encoder error. I just unzip OBS and run it, set encoder to QCOM H264 in advance settings. Here is a screen recording https://drive.google.com/file/d/1eBOS6f87sfzEMBri_S7iHpf9Afj2LOzI/view?usp=sharing OS: Windows 11 25H2 Update: MFTrace log It looks like the same error code as Sunshine, and the Buffer Size is 0B in both cases. Update again: In addition, if the encoder malfunctions, the application will freeze (become unresponsive) when the window is closed. |














Description
This PR introduces the media foundation plugin to OBS Studio, enabling Media Foundation-based encoding for H264, HEVC and AV1. This plugin supports hardware-accelerated encoding on Windows on ARM (WoA) devices, specifically those utilizing Qualcomm hardware encoders. The Key changes include:
Motivation and Context
The primary motivation for these changes is to enable hardware-accelerated encoding on Windows on ARM (WoA) devices by introducing the win-mediafoundation plugin in OBS Studio. With the growing adoption of WoA devices, ensuring OBS Studio can leverage hardware encoders on this platform improves performance and efficiency, reducing CPU load while maintaining high-quality encoding.
By integrating the mediafoundation plugin into the build system, we enable native support for Media Foundation-based encoding on WoA, ensuring users on this platform can leverage hardware acceleration for streaming and recording. This change ensures better utilization of Qualcomm hardware encoders, providing a more efficient and optimized encoding experience.
How Has This Been Tested?
The changes have been tested by building OBS Studio on a Windows on ARM (WoA) device with Qualcomm hardware. The build completed successfully, and basic functionality tests confirmed that OBS Studio runs as expected with the media foundation plugin. Media Foundation-based encoding for H264, HEVC and AV1 was verified to function correctly, ensuring proper hardware acceleration on WoA devices utilizing Qualcomm hardware.
Types of changes
Checklist: