locked
How to play an MKV video with OGG audio? RRS feed

  • Question

  • I'm going to make a transcoding tool that will also play video.
    There are two mkv files, A containing ogg audio and B containing aac audio.
    B can be played in any way.
    1) With MF/Playback(CreateVideoRendererActivate), A cannot be played.
    2) You can play A by MFCreateMediaPlayer.
    I don't want to do it the MFCreateMediaPlayer way, because I have to transcode, etc.
    I have installed ogg's decoder in the Windows Store, and the Windows built-in "TV & Video" app can also play A.
    What do I need to do to get the OGG decoder to play A correctly in my program?
    Wednesday, April 8, 2020 5:54 AM

Answers

  • Hello FyterLuo,

    Try to find if you can list Vorbis decoder (since you have installed ogg's decoder) using the following code:

    	CLSID *pDecoderCLSIDs = NULL;   // Pointer to an array of CLISDs. 
    	UINT32 cDecoderCLSIDs = 0;   // Size of the array.
    
    	HRESULT hr = MFTEnum(
    		MFT_CATEGORY_AUDIO_DECODER,
    		0,               // Reserved
    		NULL,          // Input type to match. (Encoded type.)
    		NULL,            // Output type to match. (Don't care.)
    		NULL,            // Attributes to match. (None.)
    		&pDecoderCLSIDs, // Receives a pointer to an array of CLSIDs.
    		&cDecoderCLSIDs  // Receives the size of the array.
    	);
    
    	for (UINT32 i = 0; i < cDecoderCLSIDs; i++)
    	{
    		LPWSTR pName = NULL;
    		hr = MFTGetInfo(pDecoderCLSIDs[i], &pName, NULL, NULL, NULL, NULL, NULL);
    		wprintf(L"%s\n", pName);
    	}
    For me, above code find Opus decoder.

    Then refer to Adding a Decoder to a Topology for If you want to select a particular decoder, how can you manually add a decoder to the topology.

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by FyterLuo Tuesday, April 14, 2020 1:38 AM
    Friday, April 10, 2020 9:44 AM
  • You need your own decoder for Ogg and Vorbis (meaning your own exactly or third party redistributed) because those installed with Web Media Extensions are not exposed to applications. Maybe this https://xiph.org/downloads/ can help.

    http://alax.info/blog/tag/directshow

    • Marked as answer by FyterLuo Tuesday, April 14, 2020 1:38 AM
    Monday, April 13, 2020 7:25 AM

All replies

  • Hello FyterLuo,

    From document "Supported Media Formats in Media Foundation", AAC is supported but OGG isn't.

    Can you have a check if Web Media Extensions helps? Refer to "Introducing the Web Media Extension Package with OGG Vorbis and Theora support for Microsoft Edge".

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 8, 2020 9:51 AM
  • Web Media Extensions is Edge's extension package, and I'm not sure how Edge calls it, and the article says that the extension package uses FFMpeg, which I don't want to use.

    Is there any way to specify a decoder for audio?
    For example, using MFAudioFormat_Vorbis, which is built-in to the SDK, but can't find a way to use it, and MF doesn't use it automatically.
    MFCreateMediaPlayer is capable of playing videos that contain OGG, which is a strange thing.
    Friday, April 10, 2020 6:52 AM
  • Hello FyterLuo,

    Try to find if you can list Vorbis decoder (since you have installed ogg's decoder) using the following code:

    	CLSID *pDecoderCLSIDs = NULL;   // Pointer to an array of CLISDs. 
    	UINT32 cDecoderCLSIDs = 0;   // Size of the array.
    
    	HRESULT hr = MFTEnum(
    		MFT_CATEGORY_AUDIO_DECODER,
    		0,               // Reserved
    		NULL,          // Input type to match. (Encoded type.)
    		NULL,            // Output type to match. (Don't care.)
    		NULL,            // Attributes to match. (None.)
    		&pDecoderCLSIDs, // Receives a pointer to an array of CLSIDs.
    		&cDecoderCLSIDs  // Receives the size of the array.
    	);
    
    	for (UINT32 i = 0; i < cDecoderCLSIDs; i++)
    	{
    		LPWSTR pName = NULL;
    		hr = MFTGetInfo(pDecoderCLSIDs[i], &pName, NULL, NULL, NULL, NULL, NULL);
    		wprintf(L"%s\n", pName);
    	}
    For me, above code find Opus decoder.

    Then refer to Adding a Decoder to a Topology for If you want to select a particular decoder, how can you manually add a decoder to the topology.

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by FyterLuo Tuesday, April 14, 2020 1:38 AM
    Friday, April 10, 2020 9:44 AM
  • Thanks to the pointers for adding the decoder topology node method.
    But the decoders I listed with MFTEnum is exactly the same as your list, no Vorbis (OGG) decoder.
    If I use MFAudioFormat_Vorbis to create a topology node directly, it also reports a topology error: 0xC00D5212.
    Monday, April 13, 2020 6:41 AM
  • You need your own decoder for Ogg and Vorbis (meaning your own exactly or third party redistributed) because those installed with Web Media Extensions are not exposed to applications. Maybe this https://xiph.org/downloads/ can help.

    http://alax.info/blog/tag/directshow

    • Marked as answer by FyterLuo Tuesday, April 14, 2020 1:38 AM
    Monday, April 13, 2020 7:25 AM
  • Thank you!
    Only register to DirectShow, there is no version of MediaFoundation.
    Writing my own registration program exceeded my expectations, so I'd consider using FFmpeg.
    Tuesday, April 14, 2020 1:38 AM