locked
IMFSinkWriter - Writing WMA audio/documentation

    Question

  • I am using the sink writer to write an audio stream muxed to a container.  

    To do this in a metro application, you:

    1.) Create an output mediatype, using parameters the codec supports

    2.) Create a new stream on the sink writer, passing the input media type

    3.) Create an input mediatype that matches your sample input

    4.) Set the input mediatype to that string.

    The problem is the parameters required for the output mediatype differ from encoder to encoder.  Some of the audio encoders are documented very nicely, showing what input/output media format parameters are needed. The Windows Media Audio Encoder is not documented with these, and mostly shows encoder properties.  It also makes no reference to MFAudioFormat_WMAudioV9/8.  I was able to find some examples on how to make this work , but these examples all have hardcoded values (eg AVG_BYTES_PER_SECOND) and unsure how to discover what other values can be applied.

    Is there documentation that I may have missed?  Also is there a way I can dynamically find supported formats.  Most MediaFoundation examples on this are "Desktop Only" APIs.

    Thanks!

    -Jer


    • Edited by jmorrill Friday, August 31, 2012 11:36 PM
    Friday, August 31, 2012 11:29 PM

Answers

  • Hello Jer,

    I need to apologize. I think that we have had a major failure to communicate. I believe that I understand your original question now. I will try to rephrase your original question:

    Q. "Why is there no reference to the supported output bit rates in the Windows Media Audio codec documentation?"

    A. Setting the media type on one stream can change the available types for another stream (or change the preference order). Because of this it is recommended that you query for the available output media types using "GetOutputAvailableType". However, an MFT is not required to update the list of available types dynamically. The only guaranteed way to test whether you can set a particular input type is to call IMFTransform::SetOutputType. So your methodology of testing each value is sound.

    This is all documented but I agree that it is a bit oblique and a bit of a mixed bag between what is desktop only and what is available from the WinRT environment. We will see a documentation update soon. We will continue to improve and evolve the Media Foundation documentation as we understand what technologies developers are focused on and how the technologies are being used.

    If you have any other questions that are not addressed in this post. Please post each of them separately and I will do what I can to get them answered.

    IMFTransform::GetOutputAvailableType

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms703812(v=vs.85).aspx

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, September 7, 2012 10:48 PM
    Moderator

All replies

  • Also, WRT documentation, for the MP3 Encoder, it makes reference to the MPEGLAYER3WAVEFORMAT structure.  The documentation on MPEGLAYER3WAVEFORMAT says "Desktop only", when I believe it to be desktop and metro.

    Tuesday, September 4, 2012 5:44 PM
  • Did a brute-force test on available bitrates for MFAudioFormat_WMAudioV9 (2 channel) and here are the results (HRESULT S_OK) so others don't have to go through the trouble if the documentation for this isn't found.

    The bitrates make sense, but the extra 8, 16, 24, 32, and 40 bits don't.

    MF_MT_AUDIO_AVG_BYTES_PER_SECOND : bitrate
    6003:  48,024
    8003 : 64,024
    8005 : 64,040
    10003: 80,024
    12003: 96,024
    12005: 96,040
    16002: 128,016
    16005: 128,040
    20002: 160,016
    20005: 160,040
    24002: 192,016
    24005: 192,040
    32002: 256,016
    32005: 256,040
    40001: 320,008
    40004: 320,032

    Wednesday, September 5, 2012 4:00 PM
  • Hello,

    The page referenced below should answer most of your questions. However you will need to understand how the VC1 family of codecs work to be able to create a profile manually. The details of creating manual profiles are not well documented. This is a gap in our documentation that we are considering for future documentation releases.

    http://msdn.microsoft.com/en-us/library/windows/desktop/ff819498(v=vs.85).aspx

    PS The documentation for the MP3 encoder is here below. IANAL but please keep in mind that you may need to negotiate additional licensing from Fraunhofer.

    http://msdn.microsoft.com/en-us/library/windows/desktop/hh162907(v=vs.85).aspx

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, September 6, 2012 1:07 AM
    Moderator
  • Thank you for your time again James.

    The link you posted was also one I had in my original post.  It does not list any of the valid values for MF_MT_AUDIO_AVG_BYTES_PER_SECOND.  There is no useful information listed there for a Metro environment.  In fact all the encoder values listed are not available in Metro at all.  

    In one of my posts below, I had to find valid encoding rates by incrementing and testing each value.  The AAC docs (and a couple others) do show what someone would expect to use the encoder.  I understand being behind on the documentation, but this makes it very difficult for anyone to write Metro software that leverages them.  This becomes a larger issue if indeed other codecs need to be licensed (where WM a/v codec licenses come with windows).

    If updating MSDN has a bit of red-tape, I would beg for at least an interm documentation (.docx, blog, sample, etc).  

    Thanks again for your time and any other help you can provide.

    -Jer

    Thursday, September 6, 2012 1:32 AM
  • Hello Jer,

    I need to apologize. I think that we have had a major failure to communicate. I believe that I understand your original question now. I will try to rephrase your original question:

    Q. "Why is there no reference to the supported output bit rates in the Windows Media Audio codec documentation?"

    A. Setting the media type on one stream can change the available types for another stream (or change the preference order). Because of this it is recommended that you query for the available output media types using "GetOutputAvailableType". However, an MFT is not required to update the list of available types dynamically. The only guaranteed way to test whether you can set a particular input type is to call IMFTransform::SetOutputType. So your methodology of testing each value is sound.

    This is all documented but I agree that it is a bit oblique and a bit of a mixed bag between what is desktop only and what is available from the WinRT environment. We will see a documentation update soon. We will continue to improve and evolve the Media Foundation documentation as we understand what technologies developers are focused on and how the technologies are being used.

    If you have any other questions that are not addressed in this post. Please post each of them separately and I will do what I can to get them answered.

    IMFTransform::GetOutputAvailableType

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms703812(v=vs.85).aspx

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, September 7, 2012 10:48 PM
    Moderator
  • Thanks again for your input!

    I do indeed have more questions :)  So I'll start another post for that!

    -Jer

    Friday, September 7, 2012 11:56 PM