Menu

SampleGrabber changes the ratio of image source

flash
2014-12-09
2014-12-11
  • flash

    flash - 2014-12-09

    I built a graph to grab both audio and video from a BDA DVB-T Tuner using DirectShow.

    If I build my graph like that :

    ... -> MPEG2 Demux -> BDA MPEG2 Transport Information Filter
    -> MPEG2 Sections And Tables
    -> Video Mixing Renderer 9

    The output on the renderer will be ok.

    In my case :

    ... -> MPEG2 Demux -> BDA MPEG2 Transport Information Filter
    -> MPEG2 Sections And Tables
    -> SampleGrabber -> Video Mixing Renderer 9

    The SampleGrabber changes the image ratio. Both the SampleGrabber and the renderer display some wrong images.

    I read on several topics that "SampleGrabber" can't handle dynamic formats change sent by previous filters because of the "VideoInfoHeader" structure.

    So, If the source changes the ratio, the image will be wrong in the SampleGrabber.

    What is the solution to get real images in/out the SampleGrabber without doing my own CustomSampleGrabber based on "DirectX February 2004" samples ?

     
  • snarfle

    snarfle - 2014-12-10

    Do you have some reason to believe that the format is changing? Or is that just a guess?

    Also, what makes you think the image is wrong in the sample grabber? Even if the format is changing, the SG is just giving you a bunch of bytes. If you are interpreting the bytes you get in the wrong way, that's hardly SG's fault.

    I don't believe ISampleGrabber supports dynamic format changes, so if that's what's happening, there could be a problem.

    In theory, you might be able to find out if the format has changed using the SampleCB method of ISampleGrabberCB (instead of BufferCB) and using IMediaSample::GetMediaType to get the new type. It should be easy enough to test whether a new media type is ever being sent.

    I'm not sure what you would do with this information. For example if you are writing the samples to disk, do you want to start a new file if the format changes? I don't believe many video formats like the idea of changing the media information partway thru.

    If IMediaSample doesn't work, you might be able to see the format change as an event to IMediaEvent.

    As a last resort, I suppose you could write a dmo (see the samples). If you do, then you can support IPinConnection (assuming that's what's happening) and handle the new media type there.

    Note that all of these "solutions" are guesses about things to try, since I don't actually know what the problem is here. But at least you have some things to try.

     
  • Eric

    Eric - 2014-12-11

    BDA graphs rely on various MPEG codecs and these formats are described in DirectShow with Media Types based on the VIDEOINFOHEADER2 structure.

    The built-in SampleGrabber only support media type based on the VIDEOINFOHEADER structure. By the way, I'm surprised that your video decoder filter accepts to be connected to a SG... With one are you using ?

    By using a SG, you force your video decoder filter to fall back on VIDEOINFOHEADER based media type and if you look the two structures definitions, you will see that the main difference between the two are related to aspect-ratio.

    In my opinion, you should rather find another solution than using a SampleGrabber.

     

Log in to post a comment.

MongoDB Logo MongoDB