Search code examples
videodirectshowaspect-ratiodirectshow.net

How to set aspec ratio with EVR in DirectShow?


I'm using a simple graph for video playback and EVR is my renderer. I want to force 16:9 or 16:10 aspect ratios at all times regardless of video and rendering screen native aspect ratio. Is there any way to do so?

I only managed to find IMFVideoDisplayControl::SetAspectRatioMode but it has no option to set aspect ratio manually.


Solution

  • You cannot instruct EVR to override aspect ratio, it only has option to maintain AR or not. If you want to change aspect ratio of displayed video, you have to workaround methods instead:

    1. You can transform the video feed and change media type of the stream leaving payload intact and applying new aspect ratio in respective VIDEOINFOHEADER2 structure
    2. Or, you can disable AR maintenance option on the EVR and size it appropriately, having your AR in mind. You are responsible to letterbox the space possibly left around video in this case.