How to capture video from WDM to MPEG format using DirectShow?
I wanna capture video from video so开发者_Go百科urce and encode it into MPEG format by using DirectShow. How to design Capture Graph and How to set the video properties for MPEG format (e.g. bitrate, framerate, resolution, etc.)
My approach (which I used in production of VideoPhill recorder) was to use DirectShow.net only for capturing the frames, then using SampleGrabber filter to create a queue of frames which is later fed into the encoder - I use StandardMPEG for this.
My wish was to stay in managed most of the time - and using that approach I was able to do so.
Later on - it seems like it was the right approach, because now I can attach various encoders directly to ONE capture device. And that was possible before only if you use SimulStream (tm). Not only that, but you will be able to use encoders that aren't available as a DS filter.
About using sample grabber (from DirectShow.net site - faq section):
Q9: Where do I find the BaseClasses? How do I write a filter in c#?
The base classes have not been translated to be used from .NET. After two attempts to do so, well, let's just say they weren't designed with managed code in mind.
That said, however, you do still have choices. First of all, you can use the sample grabber to capture video frames. These frames can be edited however you like before letting them continue on to the next filter in the graph. See the DxLogo sample (among others) for how this is done.
Secondly, you can write a DirectX Media Object (DMO). There are two samples included with the lib that show how this is done. While there are limitations on DMOs that regular filters don't have, you may find those limitations aren't a problem for you. There are extensive docs (including a CHM file) that talk about how to do this.
Thirdly, there is a sample named GSSF. You can use this if you want to create a source filter (ie the filter in the graph that generates the stream).
精彩评论