# Set video layout (/en/realtime-media/on-premise-recording/build/customize-the-recording/layout/linux-java)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

This guide shows you how to configure the video layout during composite recording using the On-Premise Recording SDK.

    ## Understand the tech [#understand-the-tech-1]

    In composite recording mode, the SDK renders the final video on a canvas that includes multiple user video streams. Each stream is placed in a defined region of the canvas. The canvas acts as the background, and you specify the dimensions and position of each user’s video.

    ![Composite recording canvas with user video regions](https://assets-docs.agora.io/images/on-premise-recording/user-region-canvas-diagram.png)

    <CalloutContainer type="info">
      <CalloutDescription>
        The aspect ratio of a user's video must match that of the assigned region. If the aspect ratios differ, the SDK crops the video, which can result in image loss.
      </CalloutDescription>
    </CalloutContainer>

    ## Prerequisites [#prerequisites-1]

    Before using layouts, complete the steps in the [Quickstart](/en/realtime-media/on-premise-recording/quickstart) guide to integrate the SDK and set up basic recording.

    ## Implementation [#implementation-1]

    To configure the layout, call the `setVideoMixingLayout` method and pass a `VideoMixingLayout` object that defines:

    * Canvas dimensions and frame rate
    * Background color or image
    * Layouts for each user's video

    ```java
    VideoMixingLayout recorderLayout = new VideoMixingLayout();
    recorderLayout.setCanvasWidth(1280);
    recorderLayout.setCanvasHeight(720);
    recorderLayout.setCanvasFps(25);

    // Set layout for two users
    UserMixerLayout[] layout = new UserMixerLayout[2];

    // User 1 layout
    layout[0] = new UserMixerLayout();
    layout[0].setUserId("1234");
    MixerLayoutConfig mixerLayoutConfig1 = new MixerLayoutConfig();
    mixerLayoutConfig1.setX(0);
    mixerLayoutConfig1.setY(0);
    mixerLayoutConfig1.setWidth(640);
    mixerLayoutConfig1.setHeight(360);
    layout[0].setConfig(mixerLayoutConfig1);

    // User 2 layout
    layout[1] = new UserMixerLayout();
    layout[1].setUserId("5678");
    MixerLayoutConfig mixerLayoutConfig2 = new MixerLayoutConfig();
    mixerLayoutConfig2.setX(720);
    mixerLayoutConfig2.setY(270);
    mixerLayoutConfig2.setWidth(540);
    mixerLayoutConfig2.setHeight(320);
    layout[1].setConfig(mixerLayoutConfig2);

    // Apply the layout
    recorderLayout.setUserLayoutConfigs(layout);
    agoraMediaRtcRecorder.setVideoMixingLayout(recorderLayout);
    ```

    The sample code creates the following composite layout:

    ![Composite layout](https://assets-docs.agora.io/images/on-premise-recording/composite-layout.svg)

    ## API reference [#api-reference-1]

    * [`setVideoMixingLayout`](/en/api-reference/api-ref/on-premise-recording#setvideomixinglayout)
    * [`VideoMixingLayout`](/en/api-reference/api-ref/on-premise-recording#videomixinglayout)

    
  
