Get bitmap info from MPEG-2 Program / Transport Stream?

前端 未结 1 1960
遇见更好的自我
遇见更好的自我 2021-01-16 09:04

In order to render a DirectShow graph in my WPF application, I use a sample grabber to write a bitmap to memory, and read it elsewhere in code. This may seem as a wierd solu

1条回答
  •  被撕碎了的回忆
    2021-01-16 09:17

    If you want a bitmap, you need to place the sample grabber somewhere where you receive uncompressed video. When the samplegrabber is behind the MPEG-2 Program Stream pin, you will receive a mpeg2 program stream. Of course it it possible to get a bitmap out of that, but then you need to demultiplex and decompress manually. Both are task which you want to perform in the directshow filter.

    But even if you receive uncompressed video, you might still get different formats. depending on the decoder you can receive RGB24, YUY2, YV12, ... Check the MediaSubType for what you exactly receive. If you always want to receive RGB24, you can use the RGBFilters/TransNull24 filter which is included in the sdk. See also this answer.

    Edit: One additional note, if you not only want the resolution, but also the bitmap itself, you have to put the samplegrabber between the decoder and renderer. If the MS Decoder is not working, try ffdshow.

    0 讨论(0)
提交回复
热议问题