Media Foundation multiple audio stream file decode error

1

I got an mp4 file which has 1 video and 2 audio streams. I want to decode the audio stream (after selecting one of them) using Media Foundation. Here is the code I have (I took it from MFAudio example of the MediaFoundation SDK samples).

Error checking is omitted for simplicity.

// Set up the source reader for the file.
MFCreateSourceResolver(&pSourceResolver);

pSourceResolver->CreateObjectFromURL(
    L"C:\\Users\\vahagng\\Desktop\\a.mp4",      // URL of the source.
    MF_RESOLUTION_MEDIASOURCE,  // Create a source object.
    NULL,                       // Optional property store.
    &ObjectType,                // Receives the created object type. 
    &uSource                    // Receives a pointer to the media source.
    );

uSource->QueryInterface(IID_PPV_ARGS(&mediaFileSource));

MFCreateSourceReaderFromMediaSource(mediaFileSource, NULL, &pSourceReader);

// Deselect all streams, we only want the first
pSourceReader->SetStreamSelection(MF_SOURCE_READER_ALL_STREAMS, false);
pSourceReader->SetStreamSelection(MF_SOURCE_READER_FIRST_AUDIO_STREAM, true);

MFCreateMediaType(&pAudioOutType);
pAudioOutType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
CHECK_HR(pAudioOutType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_Float);

pSourceReader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, pAudioOutType);

The code above fails on the last line (pSourceReader->SetCurrentMediaType()) with an error code 0xc00d36b4 : The data specified for the media type is invalid, inconsistent, or not supported by this object. for a media file that has 2 audio streams but works fine for 1 audio stream files.

The file I am testing has 2 AAC audio streams which is definitely supported by MediaFoundation.

Does MediaFoundation support decoding files of multiple audio streams?

c++
audio
ms-media-foundation
asked on Stack Overflow Nov 27, 2017 by mbaros • edited Dec 1, 2017 by mbaros

1 Answer

1

Microsoft AAC Audio Decoder MFT does not seem to support this flavor of AAC track/encoding.

MF_MT_MAJOR_TYPE, vValue {73647561-0000-0010-8000-00AA00389B71} (Type VT_CLSID, MFMediaType_Audio, FourCC auds)
MF_MT_SUBTYPE, vValue {00001610-0000-0010-8000-00AA00389B71} (Type VT_CLSID, MFAudioFormat_AAC, FourCC 0x00001610)
MF_MT_AM_FORMAT_TYPE, vValue {05589F81-C356-11CE-BF01-00AA0055595A} (Type VT_CLSID, FORMAT_WaveFormatEx)
MF_MT_ALL_SAMPLES_INDEPENDENT, vValue 1 (Type VT_UI4)
MF_MT_FIXED_SIZE_SAMPLES, vValue 1 (Type VT_UI4)
MF_MT_SAMPLE_SIZE, vValue 1 (Type VT_UI4)
MF_MT_AVG_BITRATE, vValue 111360 (Type VT_UI4)
MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, vValue 254 (Type VT_UI4)
MF_MT_AAC_PAYLOAD_TYPE, vValue 0 (Type VT_UI4)
MF_MT_AUDIO_AVG_BYTES_PER_SECOND, vValue 13920 (Type VT_UI4)
MF_MT_AUDIO_BITS_PER_SAMPLE, vValue 16 (Type VT_UI4)
MF_MT_AUDIO_BLOCK_ALIGNMENT, vValue 1 (Type VT_UI4)
MF_MT_AUDIO_NUM_CHANNELS, vValue 2 (Type VT_UI4)
MF_MT_AUDIO_PREFER_WAVEFORMATEX, vValue 1 (Type VT_UI4)
MF_MT_AUDIO_SAMPLES_PER_SECOND, vValue 48000 (Type VT_UI4)
MF_MT_MPEG4_CURRENT_SAMPLE_ENTRY, vValue 0 (Type VT_UI4)
MF_MT_MPEG4_SAMPLE_DESCRIPTION, vValue 00 00 00 5B 73 74 73 64 00 00 00 00 00 00 00 01 00 00 00 4B 6D 70 34 61 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 02 00 10 00 00 00 00 BB 80 00 00 00 00 00 27 65 73 64 73 00 00 00 00 03 19 00 00 00 04 11 67 15 00 01 82 00 01 DF 60 00 01 B3 00 05 02 09 90 06 01 02 (Type VT_VECTOR | VT_UI1)
MF_MT_USER_DATA, vValue 00 00 FE 00 00 00 00 00 00 00 00 00 09 90 (Type VT_VECTOR | VT_UI1)

As the decoder is unable to process the media type, the stream is not decodable for Media Foudnation, resulting in:

  • you are unable to apply decoder the way you do via SetCurrentMediaType
  • TopoEdit is unable to render the file
  • Windows Media Player can play the file falling back to DirectShow, provided that respective multiplexer, decoder is available
  • Movies and TV player plays video only and remains silent.

The audio payload is most likely okay but the track descriptor is presumably inaccurate in some part, and decoder stumbles on the problem - nevertheless minor and not fatal - and reject the file.

Specifically, it does not look the the problem is caused by multiple audio tracks in the file. The problem is related to AAC tracks.

answered on Stack Overflow Nov 27, 2017 by Roman R.

User contributions licensed under CC BY-SA 3.0