locked
Scaling with Media Foundation transform RRS feed

  • Question

  •  
    Hi
     
    I'm trying to write a transform that among other things does scaling.
    To Test it I'm using the PlaybackFX from the Media Foundation samples.
     
    The problem I encountered in is that in the transfrom filter it looks like the other parts of the topology is ok with the scaling (I'm getting SetOutputType() with the scaled size), but in the player it doesn't seem like working.
     
    I tried to get the video size using IMFVideoDisplayControl::GetNativeVideoSize() and I'm getting the original size before the scaling (the MSDN describe this function as a way to get the size prior to any stretching by the video renderer, so I expected it to be the scaled size).
     
    I also tried to set the video size to the output size of the transfrom manually, but it didn't work: when I didn't activate the scaler, the renderer stretched my video. when I did activate it the renderer showed me some smeared picture of small part of the frame.
     
     
    So, the question is how can I set the video window to be in the size of the output from the transform and to show exactly what the transform produce?
     
    Thanks.
    Haim

    Friday, August 18, 2006 1:32 PM

Answers

All replies

  • I think this question is better posted to the Media Foundation Forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=387&SiteID=1).

    Saturday, August 19, 2006 8:34 PM
  • When you call IMFVideoDisplayControl::SetVideoPosition, are you setting the destination rect or source rect? When you get a small smeared part of the frame, that tells me you're using the source rect. You should just pass NULL for that value and set the destination rect properly.

     

    Also, the only time the renderer will stretch is if the pixel aspect ratio is not 1:1. If your video does not look right, then this is probably happening.

     

    Jay Senior (MSFT)

     

    This posting is provided AS IS with no warranties and confers no rights.

    Monday, August 21, 2006 4:59 PM
  • Thanks for the answer!

    I tried to pass NULL in the source with no luck. I also tried to call IMFVideoDisplayControl::SetAspectRatioMode() with MFVideoARMode_None and got the same results.

    What is more bothering me is that GetNativeVideoSize does not seems to be affected by the media type I set in my transform, though in the transform anything is ok. is this behaviour expected?

    Thanks again!!

    Monday, August 21, 2006 8:09 PM
  • In order to properly help you, can you tell me:

    Width, height, pixel aspect ratio on the input of the EVR.

    The values returned by GetNativeVideoSize.

    Thanks.

    Jay Senior (MSFT)

    Tuesday, August 22, 2006 7:08 PM
  • The aspect ratio does seems weird...
    The GetNativeVideoSize returned video size: 320 x 240 and aspect ratio: 0x1900000 x 0x12c00000. I also checked the aspect ratio mode with GetAspectRatioMode() and it's: MFVideoARMode_PreservePicture | MFVideoARMode_PreservePixel.


    Just a small side question: the MSDN decribes pszARVideo parameter in GetNativeVideoSize as "Receives the aspect ratio of the video.", so is it the pixel aspect ratio or the video frame aspect ratio?


    To verify the correctness of the pixel aspect ratio in the transform, I checked it using MFGetAttributeSize() with MF_MT_PIXEL_ASPECT_RATIO on the IMFMediaType received in SetOutputType() and I got 1:1 pixel aspect ratio.
    The size in the SetOutputType() is also seems to be correct: 640 x 480 when doing 2x scaling but in the player it's always 320 x 240.

     

    So, obviously the aspect ratio is not correct in the player (like the video size)... How can I fix it?


    Thanks!

    Wednesday, August 23, 2006 9:46 AM
  • It sounds like the aspect ratio is correct (4x3 in all cases), but the size is not.

     

    GetNativeVideoSize returns the non-aspect ratio corrected video size as the first parameter and then the pixel aspect ratio corrected size in the second. For example, if video was 320x240, but the pixel aspect ratio was 3:4, then the sizes would be:

    (320, 240)

    (960, 960)

    The player (I assume windows media player) returns the size of the video as given by the source, and I do not believe that it takes into account pixel aspect ratio.

    This posting is provided AS IS with no warranties and confers no rights. -- Jay Senior (MSFT)

    Friday, August 25, 2006 8:56 PM
  • Thanks for the reply.

    At the end it was a bug in the type settings of my transform.

    Now I'm stuck  on the dynamic type change, as in:
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=635787&SiteID=1

    Sunday, August 27, 2006 12:41 PM