Media SDK Mpeg 2 dshow filter sample decoder with not standard resolution didn't work ok

Media SDK Mpeg 2 dshow filter sample decoder with not standard resolution didn't work ok


I'm using sample mpeg2 directshow decoder filter from sdk
3.0 beta ( software decoding mode, never tried hardware mode) .

My problem happens with a video which has a resolution of

Video Render filter (VR, VR9, EVR) shows video frames with
an aspect similar to 4:3 but in fact should be similar to 16:9.

So after doing some debug at the decoder source code I found
in CDecVideoFilter::RenewSampleParams method that VIDEOINFOHEADER2 is received
with incorrect information, struct comes with dwPictAspectRatioX = 1 and
dwPictAspectRatioy = 1 (but should be dwPictAspectRatioX = 2 and
dwPictAspectRatioy = 1) and that produces the behavior explained above.

I need some help about what's happening, and detect where
the values are wrong filled (linked library,??) of course I can
override the values manually inside the method (which actually works ) but it's
a patch that I would not like to do unless there is no other option.

I tried with a similar video (604x304) but encoded with h264
and it displays correctly with VIDEOINFOHEADER2 filled ok (dwPictAspectRatioX = 2 and
dwPictAspectRatioy = 1) also others mpeg2 decoders ( like Microsoft DTV-DVD Video
Decoder ) works ok.

Thanks in advance


8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Walter,Could you share the problem stream? I would debug at my side.Thanks,Nina

Hi Nina.

The issue happens when I stream the file through a network ( can be in same machine ).
I used Elecard networking filters to do the live stream thing.( part of the elecard codepack g4 that can be downloaded as trial )
I'll describe next the steps to reproduce the issue.

Server side

Run Network Server Transcoder from Elecard programs folder:

Chose the file I attached.
At Encoder tab select MPEG2
At network tab select Group and Transport UDP.
Push Start button

Client Side

Open graphedit.
Add Elecard NWSource-Plus filter.
At advanced settings tab set :
Multicast Group or Unicast adress:
Port : same you configured in Network server (10201 if you left the default)
Trasnport: UDP
Pyaload: MPEG2 TS

If you click apply you should see a Data Ok indicator.
Render Output pin and change mpeg2 decoder filter to intel in case is not added by default.
Play graph

You should see video renderer in a wrong resolution.

If you transcode to h264 all works fine, also if you use elecard or microsoft decoders.

Hope this helps.


Downloadvideo/x-msvideo testh.avi1.27 MB

Thanks, Walter,
Do I undestand correctly that Intel Media SDK Decoder is connected right after Elecard NWSource-Plus? Is there any Muxer on server side and Splitter on Client side involved?

Hello Nina.

Elecard Push Demuxer must be connected after NWSource-Plus, you can add it manually or it is automatically added selecting "render pin" at NWSource-Plus output.


Hi Folks,

I was able to replicate the behavior using Walters reported configuration and think I figured it out.

Both the MS and Intel filters get dwPictAspectRatioX = 1 and dwPictAspectRatioY = 1 from the Elecard PushDemuxer.

The MediaSDK filter uses these values to set the aspect ratio, while I think the Microsoft decoder calculates the aspect ratio from the rcSource->Right and rcSource->Bottom variables.

The MS docs are a bit confusing. From VideoInfoHeader2 desc: The picture aspect ratio is given by dwPictAspectRatioX and dwPicAspectRatioY. These specify the intended shape of the video when it is displayed. The pixel aspect ratio is calculated from the rcSource rectangle and the picture aspect ratio.

I think using this data you can change the Intel sample to align with the behavior you are expecting.

Hope this helps



Thanks Eric in fact if I manually changed aspect to dwPictAspectRatioX= 2 and dwPictAspectRatioY= 1 and works.
I didnt' realize yet where exactly should be the best place in the code to do a generic new calculation of aspect, I was thinking to put it on CDecVideoFilter::RenewSampleParams, but maybe the creators of the sample have a better solution...
Should be nice to have this in the 3.0 release version of the sdk.


Hi Walter,

When the upstream filter initiates a connection, CDecVideoFilter::CheckInputType is called. This is the first time the Intel filter reads those values, and this is where Id recommend calculating the new aspect ratio.


Leave a Comment

Please sign in to add a comment. Not a member? Join today