ZD Screen Recorder SDK API – ScnLib_SetLayoutContext()

ScnLib_SetLayoutContext()

Std EditionPro EditionMax EditionUltra Edition
C++ __declspec(dllimport) int __stdcall ScnLib_SetLayoutContext(int nBlock);
C# [DllImport("ScnLib.dll")] public static extern int ScnLib_SetLayoutContext(int Block);
Basic Public Declare Function ScnLib_SetLayoutContext Lib "ScnLib.dll" (ByVal Block As Int32) As Int32
Delphi function ScnLib_SetLayoutContext(Block: Integer): Integer; stdcall; external 'ScnLib.dll';
  • Description
    Set the block index of the current layout context.

  • Parameters
    • Block [in]
      The block index of the current layout context, range from -1 to 3.
      • 0 : The main screen block, which may have a webcam view overlay optionally. This is the default block.
      • 1 ~ 3 : The webcam view blocks, which will be overlaid on the main screen. Each of the webcam view blocks may output a dedicated video and/or audio file(s) optionally.
      • -1 : The composition screen block, which may also have a webcam view overlay optionally. It will encompass the main screen and all webcam views.
  • Return Value
    The block index of the previous layout context.

  • Remarks
    The SDK supports not only regular screen recording but also multi-source screen recording which can record up to five webcams along with the main screen simultaneously. You can composite the main screen block and the webcam view blocks into a single video output according to the layout you set, or even output each of the blocks to separate videos concurrently. Each layout block has its independent settings for output video path, audio path, live streaming URL, logo image, logo text, audio source, webcam device, webcam view position, and so on. Please be aware that the default settings mentioned on other API documentation pages in this manual specifically refer to the default settings of the layout context of the block #0. The table below shows the different default initial settings for each block:
    Block #0
    (Main screen)
    Block #1 ~ #3
    (Webcam views)
    Block #-1
    (Composition screen)
    Screen CaptureYesNoYes
    Video Output“C:\Users\YourName\Videos\Rec <num>.mp4”“”“”
    Audio Output“”“”“”
    Streaming URL“”“”“”
    Logo Image“”“”“”
    Logo Text“”“”“”
    Speaker AudioONOFFON
    Microphone AudioOFFONON
    Webcam DeviceOFFOFFOFF
    Webcam View PositionBottom right corner of the main screenAdjacent to the right side of the main screenTop right corner of the main screen
    Full Webcam ViewOFFAlways ONAlways OFF
    You can adjust these settings to achieve your desired outcome. The specific steps to adjust are usually as follows: First, call this API to switch the layout context to the block index that needs to be adjusted. The return value of this API is the block index of the previous layout context. It is strongly recommended that you store this block index so that you can restore to the previous layout context after the setting is completed. Then, you can call some other APIs of the SDK to configure the current block to the settings you need. Finally, restore to the previous layout context, or switch to another layout context for setting. To get the block index of the current layout context, you can call ScnLib_GetLayoutContext().

    Note: You may position a webcam view anywhere in the composition screen. While placing a webcam view in the corners of the main screen is common and usually unobtrusive, aligning it against a side of the main screen is practically the optimal position as it avoids covering any part of the main screen. The key to align a webcam view against a side of the main screen is to set negative margin values to offset it by its width or height so it appears adjacent to the main screen. Here is an example C++ code snippet to align 3 vertically stacked webcam views against the right side of 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\\MainScreen.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\\CompositionScreen.mp4"); // Restore to the previous layout context ScnLib_SetLayoutContext(oldBlock);
  • See Also
    ScnLib_GetLayoutContext()
    ScnLib_SetVideoPathA/W()
    ScnLib_SetAudioPathA/W()
    ScnLib_SetStreamingUrlA/W()
    ScnLib_SetLogoImageA/W()
    ScnLib_SetLogoTextA/W()
    ScnLib_SetCaptureRegion()
    ScnLib_RecordAudioSource()
    ScnLib_SelectWebcamDevice()
    ScnLib_SetWebcamPosition()
    ScnLib_InputWebcamFrame()
    ScnLib_RecordWebcamOnly()

Shopping Cart
  • Your cart is empty.
Scroll to Top