Table of Contents

Class VideoFrame

Namespace
LiveKit.Rtc
Assembly
LivekitRtc.dll

Represents a video frame with associated metadata and pixel data.

public class VideoFrame
Inheritance
VideoFrame
Inherited Members

Constructors

VideoFrame(int, int, VideoBufferType, byte[], Dictionary<string, object>?)

Initializes a new VideoFrame instance.

public VideoFrame(int width, int height, VideoBufferType type, byte[] data, Dictionary<string, object>? userdata = null)

Parameters

width int

The width of the video frame in pixels.

height int

The height of the video frame in pixels.

type VideoBufferType

The format type of the video frame data.

data byte[]

The raw pixel data for the video frame.

userdata Dictionary<string, object>

Optional user data dictionary.

Properties

Data

Gets the raw pixel data.

public ReadOnlySpan<byte> Data { get; }

Property Value

ReadOnlySpan<byte>

DataBytes

Gets the raw pixel data as a byte array.

public byte[] DataBytes { get; }

Property Value

byte[]

DataMutable

Gets the raw pixel data as a mutable span.

public Span<byte> DataMutable { get; }

Property Value

Span<byte>

Height

Gets the height of the video frame in pixels.

public int Height { get; }

Property Value

int

Type

Gets the format type of the video frame.

public VideoBufferType Type { get; }

Property Value

VideoBufferType

Userdata

Gets the user data associated with the frame.

public Dictionary<string, object> Userdata { get; }

Property Value

Dictionary<string, object>

Width

Gets the width of the video frame in pixels.

public int Width { get; }

Property Value

int

Methods

Clone()

Creates a copy of this video frame.

public VideoFrame Clone()

Returns

VideoFrame

A deep copy of the frame, with its own pixel buffer.

Convert(VideoBufferType, bool)

Converts the video frame to a different format type.

public VideoFrame Convert(VideoBufferType targetType, bool flipY = false)

Parameters

targetType VideoBufferType

The target format type.

flipY bool

If true, flip the frame vertically.

Returns

VideoFrame

A new VideoFrame in the target format.

Create(int, int, VideoBufferType)

Creates a new empty VideoFrame with the specified parameters.

public static VideoFrame Create(int width, int height, VideoBufferType type)

Parameters

width int

Width in pixels.

height int

Height in pixels.

type VideoBufferType

Pixel format of the buffer.

Returns

VideoFrame

A frame of that size and format with a zeroed buffer.

GetBufferSize(VideoBufferType, int, int)

Gets the buffer size in bytes for a video buffer type.

public static int GetBufferSize(VideoBufferType type, int width, int height)

Parameters

type VideoBufferType

Pixel format of the buffer.

width int

Width in pixels.

height int

Height in pixels.

Returns

int

Number of bytes a frame of that format and size occupies.

GetPlane(int)

Gets a specific plane from the video frame data.

public byte[]? GetPlane(int planeIndex)

Parameters

planeIndex int

The index of the plane (0-based).

Returns

byte[]

The plane data, or null if the index is out of bounds.

GetStride(VideoBufferType, int)

Gets the stride for a video buffer type.

public static int GetStride(VideoBufferType type, int width)

Parameters

type VideoBufferType

Pixel format of the buffer.

width int

Width in pixels.

Returns

int

Number of bytes per row of the first plane.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.