Search code examples
c++videowebcamdirectshowrecord

DirectShow webcam recording


I need to use DirectShow (C++) for recording a webcam and saving the data to a file.

I really don't know how DirectShow works, this is a "stage" (working experience), but at school we didn't study it.

I think the best way to implement this could be:

  1. List the video devices connected to the computer
  2. Select the correct camera (there will be only one)
  3. Retrieve the video
  4. Save it to a file

Now there are two problems:

  1. Where can I find a good reference book or how do I start?
  2. The saved video shouldn't be too big, does DirectShow provide a way to compress it?

I won't use OpenCV because sometime it doesn't work properly (It doesn't find the camera). Are there any high level wrapper that could help?

EDIT: the program won't have a window, it will run in background called by a dll.


Solution

  • Where can I find a good reference book or how do I start?

    DirectShow introduction material

    The saved video shouldn't be too big, does DirectShow provide a way to compress it?

    Yes it provides capabilities to attach codecs, that needs to be installed in the system. These are typically third party codecs (for reasons beyond the scope of brief answer). You might want to record into Windows Media files to not depend on third party codecs. SWee more on MSDN: Choosing a Compression Filter.