Search code examples
.netdirectshowvideo-capture

Options for predictable frame capture in .NET application


I am working in C# and have the need to capture individual frames of video files. As quickly as possible (faster than real-time), I wish to seek to a specific frame number and capture every nth frame to a graphic file format such as BMP or JPEG. It is highly desired that the frame that is captured be predictable and repeatable, i.e. do not drop frames.

I have some experience with DirectShow, but do not know if this technology is the best to use for this problem in a modern Windows .NET environment. Ideally, I would like to find a .NET or COM-based library to abstract away as much as possible. I have no need to actually display the video file on screen, and in fact would prefer not to have a Windows user interface for video playback.

Does anyone have suggestions for technologies or specific products to look into? They would need to be compatible with MPEG-2 and MPEG-4 based video files, including DivX. QuickTime support would be a nice bonus.


Solution

  • I don't see the reason why you need to do this "faster than real-time" since you're considered doing some kind processing and not displaying any video.

    I've written something similar using DirectShow.Net and .Net 2.0. Using directshow will require a bit of prior experience, or else you'll have quite a hard time trying out.

    You can also access the IMediaDet interface from windows to do the frame capture. This method is simpler but there's certain limitation to it, such as MPEG2 support. I've notice that it also doesn't support "some" flv. Check out the sample at CodeProject - FrameGrabber

    Quicktime support will mean installing QuickTimeAlternative

    I can post the code I've written using DirectShow.Net. Let me know if you need it (I need to beautify it before posting :P ).

    EDIT: NOTE: As for your "predictable" capture, there's no issue at all, as the video is not being playback at real-time, but paused, so you can seek to any point, and then extract the frame.