locked
Transcoded data into a SAR - keep getting topology status fail (MF_E_INVALIDMEDIATYPE) for event MESessionTopologyStatus RRS feed

  • Question

  • Hello Chaps

    Okay so I have an app which will decode and transcode audio from <any format> to 32KHz mono.

    This code works a treat with a custom sample grabber and has been working for ages.

    I want to add a preview button to the app to play the audio so the user can hear what they have selected before saving the setup.

    So I copied the code and created a new version - the only difference being that instead of the sample grabber I have a SAR using

    MFCreateAudioRenderer

    But when I start the session I get a topo status (111) with invalid media type - yet I haven't changed anything to do with that and it works for the sample grabber.

    If I disconnect the transcoder and connect the decode directly to the sar it plays great - but I want the user to hear the effect of the lower sample rate and mono channel mixing they have selected.

    Is this a limitation of the SAR in that it cannot play output from a transcoder?

    The way in which I set up the transcoder output is to:

    Create a new IMFMediaType and copy the output type attributes of the decoder to it.

    Then modify this media type with custom rate and reconfigure its

    MF_MT_AUDIO_NUM_CHANNELS = 1,

    MF_MT_AUDIO_SAMPLES_PER_SECOND = 32000,

    MF_MT_AUDIO_BLOCK_ALIGNMENT (the bits per sample / 8),

    NOTE: I get bits per sample by getting MF_MT_AUDIO_BITS_PER_SAMPLE

    MF_MT_AUDIO_AVG_BYTES_PER_SECOND = 32000 * block align

    This all works for my sample grabber - this part of the code has not changed.

    But it fails.

    What am I not configuring properly?

    Saturday, August 7, 2010 7:45 PM

Answers

  • The SAR only supports a limited number of formats, centering around the mix format currently used by the audio device.  Most audio devices are going to have a 2 channel mix format by default, and probably will not do conversion from mono.  MF has a resampler MFT that handles audio format mismatches; if you use the default topoloader, MF should insert this resampler and convert the audio back up to 2 channels so that it can be consumed by the SAR.

    Alternatively, you can change the mix format of the audio device for test purposes.  Go to the Sound control panel, select the device, and select properties.  In the Advanced tab, change the default format to a 1 channel format at your desired sample rate, supposing the device supports it.

    Friday, August 27, 2010 7:11 PM

All replies

  • I posted another thread about the SAR not being able to play transcoded output but no-one seemed to be able to answer my question, maybe I worded it too complex.

    Seems that if the resampler/transform does NOTHING - i.e. it's output is the same as the input (16 bit, stereo, 44100 as per decoder) - then SAR will work fine with the transform as its input.

    Even if I just change the channels from 1 to 2 (and obviously reconfig the the audio parameters to match) it fails.

    Here is a simplified version of what I am doing:


     audio_stream_transcoder->SetInputType(0, decoder_output_type, 0)

     MFCreateMediaType(&transcoder_output_type)

     decoder_output_type->CopyAllItems(transcoder_output_type)

     unsigned int channels = 2;
     unsigned int rate = 44100;

     transcoder_output_type->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, channels)
     transcoder_output_type->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, rate)

     UINT32 bits_per_sample;
     transcoder_output_type->GetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, &bits_per_sample)

     unsigned int block_align = (channels * bits_per_sample) / 8;
     transcoder_output_type->SetUINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, block_align)

     transcoder_output_type->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, rate * block_align)

     audio_stream_transcoder->SetOutputType(0, transcoder_output_type, 0)

    THIS WILL WORK FINE - But if I change channels, say to 1, or rate, say to 22050 it fails.

    I am guessing that the SAR cannot do other formats?

    Tuesday, August 10, 2010 6:34 PM
  • The SAR only supports a limited number of formats, centering around the mix format currently used by the audio device.  Most audio devices are going to have a 2 channel mix format by default, and probably will not do conversion from mono.  MF has a resampler MFT that handles audio format mismatches; if you use the default topoloader, MF should insert this resampler and convert the audio back up to 2 channels so that it can be consumed by the SAR.

    Alternatively, you can change the mix format of the audio device for test purposes.  Go to the Sound control panel, select the device, and select properties.  In the Advanced tab, change the default format to a 1 channel format at your desired sample rate, supposing the device supports it.

    Friday, August 27, 2010 7:11 PM