Eternal21
Eternal21

Reputation: 4664

Capture video to a file from webcam using C++ (MFC)

I need to add webcam video capture to a legacy MFC C++ application. The video needs to be saved as MP4. Did a bit of googling but didn't come across anything that looked promising. Any suggestions on the best approach?

EDIT: Windows platform.

EDIT: Must be compatible with XP

Upvotes: 0

Views: 3052

Answers (2)

Roman Ryltsov
Roman Ryltsov

Reputation: 69632

There are a few popular options to choose from:

  • DirectShow API - it does not have stock MPEG-4 compressors for video and audio, neither it has a stock multiplexor for .MP4 format, though there is an excellent free multiplexor from GDCL: http://www.gdcl.co.uk/mpeg4/. Also there is decent documentation, a lot of samples
  • Media Foundation API - it has everything you need (codecs, multiplexor) but only in Windows 7 (maybe even not all edtions)
  • FFmpeg and libavcodec/libavformat are definitely relevant, however H.264 encoder is only available under GPL license, not sure about video capture part right there, and you might have hard time looking for documentation and samples.

Upvotes: 1

Nicholas Smith
Nicholas Smith

Reputation: 11754

I'd say look at OpenCV as a library, hook into their video capture for that aspect, it can write out to mp4 but you'll need a couple of other libs for handling the output stream (on Linux I'd say ffmpeg and x264), that should get the buffer into the container with a reasonable amount of hassle.

Upvotes: 1

Related Questions