简体   繁体   中英

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

我会说OpenCV作为一个库,挂钩他们的视频捕获的那个方面,它可以写出到mp4但你需要一些其他的库来处理输出流(在Linux上我会说ffmpeg和x264),这应该让缓冲区进入容器并且有一定的麻烦。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM