IWMMediaProps::SetMediaType() fails with NS_E_INVALID_STREAM on video types with odd number of rows RRS feed

  • Question

  • When adding or updating streams of an ASF profile the SetMediaType method of IWMMediaProps fails with NS_E_INVALID_STREAM when the number of rows in the passed WM_MEDIA_TYPE is odd. More specific it is the member 'biHeight' of the BITMAPINFOHEADER contained within the WMVIDEOINFOHEADER of WM_MEDIA_TYPE that contains an odd number when this happens. This behaviour is not documented and it is not obvious from the error code returned. It would be helpful to learn if this issue has been resolved already or will be adressed in the future. We are dealing with industry cameras that deliver often images with an odd number of rows to utilize all pixel data an image sensor can provide.

    Development environment: MS Windows XP (SP3), MS Visual Studio 2005, MS Windows SDK for Windows Vista Updata (6000.16384.10), Windows Media Format 11 runtime, Windows Media ASF View 9 Series

    Regards, Frank.

    Wednesday, November 24, 2010 4:53 PM

All replies

  • The WMV specification requires that the video dimensions be an even number -- in fact, it is not even possible to specify an odd dimension within the WMV format.  If you have an extra line of data, you can either drop it or pad the image with an additonal line (typically black).
    Thursday, December 9, 2010 12:06 AM
  • Currently we are revising the issue internally again.

    Therefore, it would be nice if you could pinpoint me to a location where one can download the WMV specification. We are creating ASF files containing several video streams. I downloaded the Microsoft ASF specification, Revision 01.20.05 - June, 2010 (http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=14995). Section 9.2 "Video media type" does not contain any restrictions on Encoded Image Width or Height, respectively.

    Friday, September 2, 2011 8:59 AM
  • WMV9 is also known as VC-1, which is defined in the SMPTE specification 421M.  This specification can be purchased from SMPTE (http://www.smpte.org).  Essentially the lowest bit is always omitted when setting a WMV frame size and is always assumed to be 0.

    If you are using a different codec besides WMV, this check is an artifact of WMV being the most prolific codec for ASF files.  You are correct that the ASF container does not have a requirement that the width or height be even.

    Thursday, September 29, 2011 12:20 AM
  • Thanks for the helpful replies so far. We have completed our review of this issue and found that:

    1. Number of rows be even (acnowledged above) and,
    2. Number of pixels in a row has to be an integer multiple of four.

    The latter came as a little surprise and was raised by the wish to store transformed (rectified) images that can have just any dimension. OK, accepting the limitations posed by IWMMediaProps::SetMediaType() we will now store images that fullfill these requirements adding additional stream attributes about the real dimensions of the data. This is an acceptable work around.

    Thanks again,

    • Edited by fpp Monday, December 5, 2011 10:16 AM
    Monday, December 5, 2011 10:15 AM