Skip to main content
Version: 2.0.x

Custom Video Track - iOS

  • You can create a Video Track using createCameraVideoTrack() method of VideoSDK class.
  • This method can be used to create video track using different encoding parameters, camera facing mode, bitrateMode and optimization mode.

Parameters

  • encoderConfig:

    • type: CustomVideoTrackConfig
    • required: false
    • default: h360p_w640p
    • You can choose from the below mentioned list of values for the encoder config.
ConfigResolutionFrame RateOptimized (kbps)Balanced (kbps)High Quality (kbps)
h90p_w160p160x9030 fps4090120
h180p_w320p320x18030 fps60120180
h360p_w640p640x36030 fps300450600
h540p_w960p960x54030 fps6009001200
h720p_w1280p1280x72030 fps100015002000
h1080p_w1920p1920x108030 fps150025003500
h120p_w160p160x12030 fps4090120
h180p_w240p240x18030 fps90120180
h240p_w320p320x24030 fps100150200
h360p_w480p480x36030 fps270360540
h480p_w640p640x48030 fps350600900
h720p_w960p960x72030 fps90012001600
h1080p_w1440p1440x108030 fps180022003000
note

Above mentioned encoder configurations are valid for both, landscape as well as portrait mode.

  • facingMode:

    • type: AVCaptureDevice.Position
    • required: false
    • Allowed values : .front | .back
    • It will specify whether to use front or back camera for the video track.
  • multiStream

    • type: boolean
    • required: false
    • default: true
    • It will specify if the stream should send multiple resolution layers or single resolution layer.
  • codec

    • type: String
    • required: false
    • default: VP8
    • A video codec for compresses video data for efficient transmission over the internet, balancing quality and bandwidth usage.
  • bitrateMode:

    • type: BitrateMode
    • required: false
    • Allowed values : BitrateMode.BANDWIDTH_OPTIMIZED | BitrateMode.BALANCED | BitrateMode.HIGH_QUALITY
    • Controls the video quality and bandwidth consumption. You can choose between BitrateMode.HIGH_QUALITY for the best picture, BitrateMode.BANDWIDTH_OPTIMIZED to save data, or BitrateMode.BALANCED for a mix of both. Defaults to BitrateMode.BALANCED.
  • maxLayer:

    • type: EncodingLayer
    • required: false
    • Allowed values : MAX_LAYER_2 | MAX_LAYER_3
    • default: MAX_LAYER_3
    • Specifies the maximum number of simulcast layers to publish. This parameter only has an effect if multiStream is set to true.
info
  • To learn more about optimizations and best practices for using custom video tracks, follow this guide.
  • This parameter is only available from v2.0.6.

Returns

  • RTCVideoTrack

Example

guard let videoMediaTrack = try? VideoSDK.createCameraVideoTrack(
encoderConfig: .h720p_w1280p,
facingMode: .front,
multiStream: true,
codec: .H264, // Default: .VP8
bitrateMode: .HIGH_QUALITY, // Default: .BALANCED,
maxLayer: .MAX_LAYER_2 // Default: .MAX_LAYER_3
) else { return }

Custom Audio Track

  • You can create a Video Track using createAudioTrack() method of VideoSDK class.
  • This method can be used to create audio track using different noise configs.

Parameters

  • noiseConfig

    • noiseSuppression

      • type: Bool
      • required: false
      • If true, noise suppression would be turned on; otherwise, it would be off.
    • echoCancellation

      • type: Bool
      • required: false
      • If true, echo cancellation would be turned on; otherwise, it would be off.
    • autoGainControl

      • type: Bool
      • required: false
      • If true, autogain control would be turned on; otherwise, it would be off.
    • highPassFilter

      • type: Bool
      • required: false
      • If true, highpass filter would be turned on; otherwise, it would be off.

Returns

  • RTCAudioTrack

Example

guard
let audioMediaTrack = try? VideoSDK.createAudioTrack(
noiseConfig: noiseConfig(
noiseSupression: true,
echoCancellation: true,
autoGainControl: true,
highPassFilter: true
)
)
else { return }

Got a Question? Ask us on discord