Record a video via a usb WebCam in csharp

c#, webcam

Solution

Video capture APIs in Windows are:

- Video for Windows (simple, limited, deprecated, really outdated)

- DirectShow

- Media Foundation

All three are native APIs, so you need wrappers to interface from managed code. #3 is supposed to be a successor to #2 but reality makes #2 still the best - in general terms - API for video capture out there. In particular, Expression Encoder uses DirectShow.

DirectShow.NET lets you do DirectShow from C#, and it has `CapWMV` Sample for you:

Capture from video capture devices to WMV files.

`MFCaptureToFile` Sample shows you ho to achieve video capture via Media Foundation:

Shows how to capture video from a video camera to a file.

Problem

I have a simple use case. Where I want to display a usb webcam and record the the live video(Not as screen capture). I have checked these links 1) WebCam 2)Simple Webcam But it does not show how to record a video. Can I extend these to record a video or should I look at some other dll ? Edit: Currently I am using Expression encoder SDK, but is giving a issue with a specific use case (Question)

Original source