createCameraVideoTrack static method

dynamic createCameraVideoTrack({
  1. String? cameraId,
  2. CustomVideoTrackConfig encoderConfig = CustomVideoTrackConfig.h720p_w1280p,
  3. FacingMode facingMode = FacingMode.user,
  4. bool multiStream = true,
  5. BitrateMode bitrateMode = BitrateMode.BALANCED,
  6. int maxLayer = 3,
})

Creates a camera-based video track with customizable capture and encoding configurations.

This method allows you to create a custom video track using a camera device with configurable resolution, frame rate, camera facing mode, and multi-stream support.

Parameters

  • cameraId (optional): The device ID of the camera from which the video should be captured. If not provided, the default camera will be used.

  • encoderConfig (optional): The video encoder configuration to be used for the video track. Defaults to CustomVideoTrackConfig.h720p_w1280p.

    Note: These encoder configurations are valid for both landscape and portrait orientations.

  • facingMode (optional): Specifies which camera to use for video capture. Defaults to FacingMode.user.

    Allowed values:

  • multiStream (optional): Determines whether multiple resolution layers should be sent for the video stream. Defaults to true.

    Info:

    • For meetings with four or fewer participants, setting multiStream: false is recommended for better performance.
    • Available from SDK version v1.0.9.
  • bitrateMode (optional): Controls how the bitrate is managed for the video stream. Defaults to BitrateMode.BALANCED.

  • maxLayer (optional): Specifies the maximum number of simulcast layers to publish. Valid values are between 1 and 3. Defaults to 3.

Returns

  • A Future that resolves to a CustomTrack representing the created video track, or null if video track creation fails.

Example

final CustomTrack? videoTrack =
    await VideoSDK.createCameraVideoTrack(
      encoderConfig: CustomVideoTrackConfig.h1440p_w1920p,
      facingMode: FacingMode.user,
      multiStream: false,
      bitrateMode: BitrateMode.BALANCED,
      maxLayer: 2,
    );

if (videoTrack != null) {
  print('Video track created successfully');
}

Implementation

static createCameraVideoTrack({
  String? cameraId,
  CustomVideoTrackConfig encoderConfig = CustomVideoTrackConfig.h720p_w1280p,
  FacingMode facingMode = FacingMode.user,
  bool multiStream = true,
  BitrateMode bitrateMode = BitrateMode.BALANCED,
  int maxLayer = 3,
}) =>
    _createCameraVideoTrack(
        cameraId: cameraId,
        encoderConfig: encoderConfig,
        facingMode: facingMode,
        multiStream: multiStream,
        bitrateMode: bitrateMode,
        maxLayer: maxLayer);