How to record video and audio from webcam using opencv and vc++ and also the recorded video should be played in windows media player

asked 2013-12-12 22:47:34 -0500

Arvind gravatar image

updated 2013-12-12 22:50:45 -0500

I have currently created an application where i can click pictures from web camera and now i want to record video from web camera and play that respective video in Windows Media Player. I am able to record the video and also the video is getting played in VLC player but not in windows media player. Also i want to record audio with video using web camera but curretly i am able to record only video. I did lot of search in google and got to know that FFMPEG can be used to record both video and audio but couldnt undestand how it can be done. The list of codecs which I used and the video is successfully getting played in VLC player are

cv::VideoWriter *writer2 = new cv::VideoWriter(chPath,CV_FOURCC('X','v','I','D'),24,imgSize,-1);

CvVideoWriter *writer = cvCreateVideoWriter("D:\arvind_workspace\test_m452.avi",CV_FOURCC('M','4','S','2'),15,imgSize,-1);

CvVideoWriter *writer = cvCreateVideoWriter("D:\arvind_workspace\test_mp4s.avi",CV_FOURCC('M','P','4','S'),15,imgSize,-1);

CvVideoWriter *writer = cvCreateVideoWriter(chPath,CV_FOURCC('M','P','4','V'),15,imgSize,-1);

CvVideoWriter *writer = cvCreateVideoWriter("D:\arvind_workspace\test.avi",CV_FOURCC('M','S','V','C'),15,imgSize,-1);

CvVideoWriter *writer = cvCreateVideoWriter(chPath,-1,15,imgSize,1);

CvVideoWriter *writer = cvCreateVideoWriter(chPath,CV_FOURCC('D','I','V','X'),15,imgSize,1);

CvVideoWriter writer = cvCreateVideoWriter(chPath,/CV_FOURCC_DEFAULT*/CV_FOURCC('M', 'J', 'P', 'G'),24,imgSize,-1);

These are the list of codec which are successfully playing in VLC player but not in Windows MEdia Player and also Audio is not getting recorded. Is there any specific codec for WIndows Media Player

Can any of you please help me with this thing Atleast if the video gets played in Windows Media Player would be good enough for time being.

edit retag flag offensive close merge delete


there is no audio in opencv .

berak gravatar imageberak ( 2013-12-13 03:13:30 -0500 )edit