Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing project in which I want to capture video from two webcam at same time from two different side.
But when I started recording from both webcam it shows "END RECORDING" status ;
But when I started recording single webcam it record a video.
I am mentioning the code used for recording.
Also I am using vfw32 library of Microsoft Sdks for this webcam functionality.

C++
//CONNECTION FOR WEBCAM1

hMyWindow1 = capCreateCaptureWindow("", WS_CHILD |WS_VISIBLE,rect.left, rect.top,rect.right,rect.bottom, hw, 0);

capSetCallbackOnStatus(   hMyWindow1,    capStatusCallback1);

SendMessage(hMyWindow1,WM_CAP_DRIVER_CONNECT,0,0);

SendMessage(hMyWindow1, WM_CAP_SET_SCALE, true , 0);
SendMessage(hMyWindow1, WM_CAP_SET_PREVIEWRATE, 66, 0);
SendMessage(hMyWindow1, WM_CAP_SET_PREVIEW, true , 0);
SendMessage(hMyWindow1,WM_CAP_DLG_VIDEOSOURCE,0,0);


//CONNECTION FOR WEBCAM2

hMyWindow = capCreateCaptureWindow("", WS_CHILD |WS_VISIBLE,rect.left, rect.top,rect.right,rect.bottom, hw, 0);

capSetCallbackOnStatus(   hMyWindow,    capStatusCallback1);

SendMessage(hMyWindow,WM_CAP_DRIVER_CONNECT,0,0);

SendMessage(hMyWindow, WM_CAP_SET_SCALE, true , 0);
SendMessage(hMyWindow, WM_CAP_SET_PREVIEWRATE, 66, 0);
SendMessage(hMyWindow, WM_CAP_SET_PREVIEW, true , 0);
SendMessage(hMyWindow,WM_CAP_DLG_VIDEOSOURCE,0,0);


//RECORDING CODE


p=SendMessage(hMyWindow,WM_CAP_FILE_SET_CAPTURE_FILE , 0,(LPARAM) (LPVOID) cname1);
                 p=  SendMessage(hMyWindow, WM_CAP_GET_SEQUENCE_SETUP, sizeof(CaptureParams),(LPARAM) (LPVOID)(LPCAPTUREPARMS)&CaptureParams);
                 CaptureParams.dwRequestMicroSecPerFrame=14286;/// its for 70 fps(1000000/70) bt giving fps of 60
                 CaptureParams.fYield=1;

                   //p=  SendMessage(hMyWindow, WM_CAP_GET_SEQUENCE_SETUP, sizeof(CaptureParams),(LPARAM) (LPVOID)(LPCAPTUREPARMS)&CaptureParams);
                 p=  SendMessage(hMyWindow, WM_CAP_SET_SEQUENCE_SETUP, sizeof(CaptureParams),(LPARAM) (LPVOID)(LPCAPTUREPARMS)&CaptureParams);
                 p=SendMessage(hMyWindow, WM_CAP_SEQUENCE, 0, 0);





                 p=SendMessage(hMyWindow1,WM_CAP_FILE_SET_CAPTURE_FILE , 0,(LPARAM) (LPVOID) cname2);
                 p=  SendMessage(hMyWindow1, WM_CAP_GET_SEQUENCE_SETUP, sizeof(CaptureParams),(LPARAM) (LPVOID)(LPCAPTUREPARMS)&CaptureParams);
                CaptureParams.dwRequestMicroSecPerFrame=14286;/// its for 70 fps(1000000/70) bt giving fps of 60
                 CaptureParams.fYield=1;
                 p=  SendMessage(hMyWindow1, WM_CAP_SET_SEQUENCE_SETUP, sizeof(CaptureParams),(LPARAM) (LPVOID)(LPCAPTUREPARMS)&CaptureParams);
SendMessage(hMyWindow1, WM_CAP_SEQUENCE, 0, 0);
SetWindowText(GetDlgItem(hDlg, IDC_START_CAPTURE), "Stop Capture");
Posted
Updated 20-Dec-11 10:55am
v2

That may sound stupid, but are trying to record to the same file from 2 different sources? that might be the problem?!?
 
Share this answer
 
Comments
TRUSHAL RANE 20-Dec-11 6:58am    
I want to make two video file from two webcam
In some computer this code work perfectly but in some computer it gives error.
Can you tell me "how to disable audio driver of webcam?"
Hi,

Please make sure that you are using the right index value for WM_CAP_DRIVER_CONNECT.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900