ZD Screen Recorder SDK Advanced – Visual C++

Advanced Visual C++ example code snippet demonstrates how to conduct recording multiple webcams along with the main screen



// Switch the layout context to the main screen block and store the
// previous block index
int oldBlock = ScnLib_SetLayoutContext(0);

// Output a separate video for the main screen (OPTIONAL)
ScnLib_SetVideoPathW(L"C:\\Recordings\\Main Screen.mp4");

// Retrieve the main screen video resolution
int videoWidth = 0, videoHeight = 0;
ScnLib_GetVideoResolution(&videoWidth, &videoHeight);

// We are going to align 3 vertically stacked webcam views against 
// the right side of the main screen, each is 1/3 of the video height
videoHeight /= 3;
// We prefer webcam views with a 4:3 aspect ratio
videoWidth = videoHeight * 4 / 3;

// Switch the layout context to the webcam view block #1
ScnLib_SetLayoutContext(1);

// Output a separate video for the webcam #1 view (OPTIONAL)
ScnLib_SetVideoPathW(L"C:\\Recordings\\Webcam #1.mp4");

// Assuming there are more than 3 webcam devices connected to the PC, 
// select the first webcam device for the webcam #1 view
ScnLib_SelectWebcamDevice(0);

// Align webcam #1 view to the top right corner, offsetting it by its 
// width to the right so it appears adjacent to the main screen
ScnLib_SetWebcamPosition(SCNLIB_POSITION_TOP_RIGHT, -videoWidth, 0);
ScnLib_SetWebcamViewSize(videoWidth, videoHeight);

// Switch the layout context to the webcam view block #2
ScnLib_SetLayoutContext(2);

// Output a separate video for the webcam #2 view (OPTIONAL)
ScnLib_SetVideoPathW(L"C:\\Recordings\\Webcam #2.mp4");

// Assuming there are more than 3 webcam devices connected to the PC, 
// select the second webcam device for the webcam #2 view
ScnLib_SelectWebcamDevice(1);

// Align webcam #2 view to the right side, also offsetting it by its 
// width to the right so it appears adjacent to the main screen
ScnLib_SetWebcamPosition(SCNLIB_POSITION_RIGHT, -videoWidth, 0);
ScnLib_SetWebcamViewSize(videoWidth, videoHeight);

// Switch the layout context to the webcam view block #3
ScnLib_SetLayoutContext(3);

// Output a separate video for the webcam #3 view (OPTIONAL)
ScnLib_SetVideoPathW(L"C:\\Recordings\\Webcam #3.mp4");

// Assuming there are more than 3 webcam devices connected to the PC, 
// select the third webcam device for the webcam #3 view
ScnLib_SelectWebcamDevice(2);

// Align webcam #3 view to the bottom right corner, offsetting it by 
// its width to the right so it appears adjacent to the main screen
ScnLib_SetWebcamPosition(SCNLIB_POSITION_BOTTOM_RIGHT, -videoWidth, 0);
ScnLib_SetWebcamViewSize(videoWidth, videoHeight);

// Switch the layout context to the composition screen
ScnLib_SetLayoutContext(-1);

// Output a separate video for the composition screen
ScnLib_SetVideoPathW(L"C:\\Recordings\\Composition Screen.mp4");

// Restore to the previous layout context
ScnLib_SetLayoutContext(oldBlock);

// Start the recording session right now
ScnLib_StartRecording();
Referenced APIs:
Shopping Cart
  • Your cart is empty.
Scroll to Top