-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
mediafoundation: Introduce Media Foundation-based encoding support on WoA #11993
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
base: master
Are you sure you want to change the base?
Conversation
55aa652 to
ea69f55
Compare
PatTheMav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@thirumalai-qcom did you have a chance to review these notes as well? |
06727f5 to
2df9b97
Compare
@derrod Thanks for Confirming.
Apologies for the delayed response, there were some internal discussions on this. The AAC related changes have been dropped from this PR.
There are also plans to add AV1 support. I'll get back on this shortly.
@PatTheMav @derrod |
2df9b97 to
353400c
Compare
353400c to
4554231
Compare
c299d3b to
69c00db
Compare
Just as a heads-up, because there's another PR that introduces support for Media Foundation-based capture devices, we have a potential conflict between both using the I suggested a solution to this on the other PR that I'd recommend this PR leans into as well: #10471 (comment) |
69c00db to
88a6b4c
Compare
Happy to announce, AV1 support has now been successfully integrated into this PR. 🥳 The CI-generated binaries of this PR include AV1 functionality.
@PatTheMav, Thanks for the heads-up regarding the potential conflict with the win-mf subdirectory. I've reviewed your suggestion and applied the recommended changes. Please take a look and let me know if any further improvements are needed. |
88a6b4c to
d35e742
Compare
Sorry for the delayed response - I saw that, much appreciated. I'll have to look into both PRs a bit more closely as both initially wanted to "be" |
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.
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.
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.
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.
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.
d35e742 to
19a4f9f
Compare
|
Hi @RytoEX & @PatTheMav |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine apart from the few things I found. This will probably require a small refactor to change the plugin ID and also final output directory once we have guidance, but those should be less impactful final changes.
| add_library(win-mf MODULE) | ||
| add_library(OBS::win-mf ALIAS win-mf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small heads-up, this name will need to change (here and throughout the plugin code) as it should distinguish itself from the Media Foundation-based capture plugin. I asked for guidance what that name should be, so that'd hopefully just be a final "refactor->rename" operation.
| mf-common.cpp | ||
| mf-encoder-descriptor.cpp | ||
| mf-h264-encoder.cpp | ||
| mf-h264.cpp | ||
| mf-hevc-encoder.cpp | ||
| mf-av1.cpp | ||
| mf-av1-encoder.cpp | ||
| mf-hevc.cpp | ||
| mf-plugin.cpp | ||
| mf-common.hpp | ||
| mf-encoder-descriptor.hpp | ||
| mf-h264-encoder.hpp | ||
| mf-hevc-encoder.hpp | ||
| mf-av1-encoder.hpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be sorted alphabetically.
| CHECK_HR_ERROR(o->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlaceMode::MFVideoInterlace_Progressive)); | ||
| CHECK_HR_ERROR(MFSetAttributeRatio(o, MF_MT_PIXEL_ASPECT_RATIO, 1, 1)); | ||
| CHECK_HR_ERROR(o->SetUINT32(MF_MT_VIDEO_LEVEL, (UINT32)-1)); | ||
| //CHECK_HR_ERROR(o->SetUINT32(MF_MT_MPEG2_PROFILE, MapProfile(profile))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason to retain this as a comment, or is this unused and thus can be removed?
| //#undef MFTEXT | ||
| //#undef MFP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If those lines are not needed anymore, they should be removed.
| //#undef MFTEXT | ||
| //#undef MFP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If those lines are not needed anymore they should be removed.
| } | ||
|
|
||
| OBS_DECLARE_MODULE() | ||
| OBS_MODULE_USE_DEFAULT_LOCALE("win-mf", "en-US") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above, the id will need to change. Will reply back once we have guidance for the preferred name.





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 reintroducing the win-mf 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: