Skip to content

win-mf: Reintroduce win-mf plugin for Media Foundation-based encoding 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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thirumalai-qcom
Copy link
Contributor

Description

This PR re-introduces the win-mf plugin to OBS Studio, enabling Media Foundation-based encoding for H264, HEVC, and AAC. This plugin was previously removed in PR #7372 but is now being restored to support hardware-accelerated encoding on Windows on ARM (WoA) devices, specifically those utilizing Qualcomm hardware encoders. The Key changes include:

  • win-mf: Add base files for MFT encoders support on WoA
  • win-mf: Add Media Foundation H264 encoder for WoA
  • win-mf: Add Media Foundation HEVC encoder for WoA
  • win-mf: Add Media Foundation ACC encoder for WoA
  • cmake: Add win-mf plugin to OBS build for WoA

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 win-mf plugin back 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 reintroduced win-mf plugin. Media Foundation-based encoding for H264, HEVC, and AAC was verified to function correctly, ensuring proper hardware acceleration on WoA devices utilizing Qualcomm hardware.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@WizardCM WizardCM added Seeking Testers Build artifacts on CI New Feature New feature or plugin labels Mar 24, 2025
@thirumalai-qcom thirumalai-qcom force-pushed the mft-support branch 2 times, most recently from 55aa652 to ea69f55 Compare March 25, 2025 11:32
@thirumalai-qcom thirumalai-qcom marked this pull request as ready for review March 25, 2025 11:55
Copy link
Member

@PatTheMav PatTheMav left a 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 static functions is deprecated in C++ (static functions are only used for class methods in modern C++).
  • Use of constexpr as 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be adapted to current CMake guidelines instead of copied-over from the legacy variant.

@@ -88,3 +88,4 @@ add_obs_plugin(vlc-video WITH_MESSAGE)
add_obs_plugin(win-capture PLATFORMS WINDOWS)
add_obs_plugin(win-dshow PLATFORMS WINDOWS)
add_obs_plugin(win-wasapi PLATFORMS WINDOWS)
add_obs_plugin(win-mf PLATFORMS WINDOWS ARCHITECTURES ARM64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win-mf should appear between win-dshow and win-wasapi, following alphabetical sorting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, Thanks for pointing that out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd advise to only add the en-US language file and have it translated again.

@RytoEX WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree.

@derrod
Copy link
Member

derrod commented Mar 25, 2025

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.

obs_encoder_info info = {};
info.id = "mf_aac";
info.type = OBS_ENCODER_AUDIO;
info.codec = "AAC";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code name needs to be lowercase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for pointing that out.

This commit re-introduces the base files required for Media Foundation
Transform (MFT) support in the win-mf plugin, specifically targeting
Windows on ARM (WoA) devices with Qualcomm hardware. It includes core
implementation files, language configuration files 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.

Additionally, CMakeLists.txt is updated to include the new source and
header files for proper integration into the win-mf plugin.
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.

Additionally, CMakeLists.txt is updated to include the new source and
header files for proper integration into the win-mf plugin.
This commit introduces AAC encoder support using the Media Foundation
Transform (MFT) interface, specifically targeting Windows on ARM (WoA)
devices with Qualcomm hardware. It adds mf-aac.cpp and
mf-aac-encoder.cpp/.hpp to implement the encoding logic.

Additionally, CMakeLists.txt is updated to include the new source and
header files for proper integration into the win-mf plugin
This commit updates the CMakeLists.txt file in the plugins directory to
incorporate the win-mf plugin into the OBS build system. This change
ensures that Media Foundation-based encoding is available for Windows
on ARM (WoA) devices, utilizing Qualcomm hardware for efficient video
Encoding.
@dd-han
Copy link

dd-han commented Apr 13, 2025

Will this work with my older Surface Pro X (SQ2)?

If it works I can help test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature New feature or plugin Seeking Testers Build artifacts on CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants