'Using Media Foundation API to disable specific decoders
I have a project which has Windows Media Player embedded. Using the Media Foundation API, how do I disable mp4 and mkv file formats? So Windows Media Player will use third-party decoders for mp4 and mkv file formats instead. (Which in my case is FFDSHOW, I want to use its H264 decoder for mp4 and mkv file formats instead of Media Foundation decoders).
I heard that there's a third-party software named Codec Tweak Tool which does the job, probably it's using Media Foundation API to achieve that.
Using Codec Tweak Tool and a Win registry debugger I found out a few registry directories which may be related to Media Foundation.
I tried to change a registry in the following Win registry directory: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Media Foundation\ByteStreamHandlers\.mkv (Windows 10 64-Bit directory), but the system doesn't give me permission, using registry seems like a hacky way to change it though, I get access denied by the way. I don't think that's the right way to do it. I heard that I can achieve the same by using the Media Foundation API, maybe using Media Foundation Transforms or a Source Resolver, but I don't know how to set a proper object and work with the API interfaces to do such a thing. However I know that after disabling it, I should set a preferred directShow decoder such as FFDSHOW so it'll be used instead of the Media Foundation for those respective file formats which I'm suppose to disable.
After using Codec Tweak Tool to change H264 preferred decoder, I found out which registries are changed after setting a preferred directShow decoder.
Key directory:
HKLM\SOFTWARE\WOW6432Node\Microsoft\DirectShow\Preferred (Windows 10 64-Bit directory)
Registries that have been chaged:
{31435641-0000-0010-8000-00AA00389B71}
{34363248-0000-0010-8000-00AA00389B71}
{34363268-0000-0010-8000-00AA00389B71}
and applied the following FFDSHOW CLSID to each of them: {04FE9017-F873-410E-871E-AB91661A4EF7}
I also noticed that the CLSID is required to set a preferred decoder.
I've come to the conclusion that working with registry is definitely not the right way to achieve that, so how to do that by using the Media Foundation API? I've read the Media Foundation API documentation but it seems confusing for me due to the low level and complexity it takes.
Solution 1:[1]
You can try to change the correspondive bytestream handler registry key by first changing the owner rights from Trusted Installer to Administrators and then give Administrators 'full access'- or 'edit subkey'-rights to the registry key object by right-clicking on the key entry in windows registry editors left window. After that, don't forget to reset the access rights to 'read only'...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
