Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Viewing MPEG-1 stream (not from file)

Hello experts,

I want to write an application that accepts MPEG-1 video buffers from a video card and displays them on the screen.

The video card is not a standard capture device. It supplies buffers that contain MPEG-1 data. The buffers boundaries do not comply to the MPEG-1 standard (MPEG packets are cut between buffers).

I use DirectShow to write the application.
I started to write a source filter (derived from CSource & uses CSourceStream) that accepts the buffers from the card and passes them on to the 'MPEG-1 Stream splitter'. I failed to connect my filter to the 'Stream Splitter' (probably some of my media type information was incorrect).

Is the 'MPEG-1 Stream splitter' provided with DirectShow capable of accepting real-time video stream?
Is my approach for displaying live video correct?
If so, can I get help as to how to write the filter?
1 Solution

The software you are trying to write will look like a Video Capture filter connected to an MPEG decoder filter.  There are two approaches - (A) connect to the standard MPEG splitter and decoder, or (B) write a custom decoder and connect directly to it.  

For A, you have to make the media types match.  Chances are that your capture device does not deliver data that exactly matches the MPEG-1 format, so you may have to fill in the holes.  If you have video only, you need Stream/MPEG1Video.  If you have audio and video, you need Stream/MPEG1System.

For B, you could allow connection to any media type (assume it's always correct) and decode your custom data format directly.  For a sample video decoder, see the code at http://cedar.intel.com/cgi-bin/ids.dll/content/content.jsp?cntKey=Generic+Editorial%3a%3aht_videoEncode&cntType=IDS_EDITORIAL&catCode=CUY.

When you connect your source filter, you may need to push some dummy data out to the output pin if you haven't already loaded the MPEG header data from your capture card.  The connection algorithm looks for a specific pattern of bytes in the source stream, so you have to fill it in according to the MPEG-1 spec.

Hope that helps,

 - ep
yossikallyAuthor Commented:

Thanks for your comment.

I think solution 'A' will be good for me (less work). I looked at the ASyncReader example in MSDN. This example loads a file to memory and and supplies chuncks of the file to the filters/renderer.
Do you think I can implement a source filter in the same way? My capture device (which is a device driver for a specific video compression card) produces MPEG-1 buffers. I will send these buffers to the MPEG-1 splitter the same way the chunks of files are sent in the ASyncReader example. One thing I'm still not sure is how do I control the rate in this case? Do I pass each buffer as soon as the renderer/splitter asks for it?
PAQed, with points refunded (200)

E-E Admin

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now