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
widthintThe width of the video frame in pixels.
heightintThe height of the video frame in pixels.
typeVideoBufferTypeThe format type of the video frame data.
databyte[]The raw pixel data for the video frame.
userdataDictionary<string, object>Optional user data dictionary.
Properties
Data
Gets the raw pixel data.
public ReadOnlySpan<byte> Data { get; }
Property Value
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
Height
Gets the height of the video frame in pixels.
public int Height { get; }
Property Value
Type
Gets the format type of the video frame.
public VideoBufferType Type { get; }
Property Value
Userdata
Gets the user data associated with the frame.
public Dictionary<string, object> Userdata { get; }
Property Value
Width
Gets the width of the video frame in pixels.
public int Width { get; }
Property Value
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
targetTypeVideoBufferTypeThe target format type.
flipYboolIf 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
widthintWidth in pixels.
heightintHeight in pixels.
typeVideoBufferTypePixel 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
typeVideoBufferTypePixel format of the buffer.
widthintWidth in pixels.
heightintHeight 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
planeIndexintThe 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
typeVideoBufferTypePixel format of the buffer.
widthintWidth 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.