VideoFrame

Video frame property settings.

export class VideoFrame {

  type?: VideoPixelFormat;

  width?: number;

  height?: number;

  yStride?: number;

  uStride?: number;

  vStride?: number;

  yBuffer?: Uint8Array;

  uBuffer?: Uint8Array;

  vBuffer?: Uint8Array;

  rotation?: number;

  renderTimeMs?: number;

  avsync_type?: number;

  metadata_buffer?: Uint8Array;

  metadata_size?: number;

  textureId?: number;

  matrix?: number[];

  alphaBuffer?: Uint8Array;

  alphaStitchMode?: AlphaStitchMode;

  colorSpace?: ColorSpace;
}

The buffer is provided as a pointer to a pointer. This interface cannot modify the buffer pointer, only the buffer content.

Properties

type
Pixel format. See VideoPixelFormat.
width
Video pixel width.
height
Video pixel height.
yStride
For YUV data, indicates the row stride of the Y buffer; for RGBA data, indicates the total data length.
Note: When processing video data, you need to handle the offset between rows of pixel data according to this parameter, otherwise image distortion may occur.
uStride
For YUV data, indicates the row stride of the U buffer; for RGBA data, the value is 0.
Note: When processing video data, you need to handle the offset between rows of pixel data according to this parameter, otherwise image distortion may occur.
vStride
For YUV data, indicates the row stride of the V buffer; for RGBA data, the value is 0.
Note: When processing video data, you need to handle the offset between rows of pixel data according to this parameter, otherwise image distortion may occur.
yBuffer
For YUV data, indicates the pointer to the Y buffer; for RGBA data, indicates the data buffer.
uBuffer
For YUV data, indicates the pointer to the U buffer; for RGBA data, the value is empty.
vBuffer
For YUV data, indicates the pointer to the V buffer; for RGBA data, the value is empty.
rotation
Sets the clockwise rotation angle of the frame before rendering the video. Currently supports 0, 90, 180, and 270 degrees.
renderTimeMs
The Unix timestamp (in milliseconds) when the video frame is rendered. This timestamp can be used to guide video frame rendering. This parameter is required.
avsync_type
Reserved parameter.
metadata_buffer
This parameter applies only to video data in Texture format. Indicates the data buffer of MetaData. Default is NULL.
metadata_size
This parameter applies only to video data in Texture format. Indicates the size of MetaData. Default is 0.
textureId
This parameter applies only to video data in Texture format. Texture ID.
matrix
This parameter applies only to video data in Texture format. A 4x4 transformation matrix input, typically an identity matrix.
colorSpace
The color space property of the video frame. By default, Full Range and BT.709 standard configuration is applied. You can customize this setting based on your custom capture and rendering needs. See VideoColorSpace.
alphaBuffer
Alpha channel data output by the portrait segmentation algorithm. This data matches the size of the video frame. Each pixel value ranges from [0, 255], where 0 represents the background and 255 represents the foreground (portrait). You can use this parameter to render the video background with various effects, such as transparency, solid color, image, video, etc.
Note:
  • In custom video rendering scenarios, ensure that both the video frame and alphaBuffer are of Full Range type; other types may cause abnormal Alpha data rendering.
  • Make sure that alphaBuffer matches the video frame size (width × height) exactly, otherwise the app may crash.
alphaStitchMode
When the video frame contains Alpha channel data, sets the relative position between alphaBuffer and the video frame. See AlphaStitchMode.
metaInfo
Metadata in the video frame. This parameter requires contacting technical support to use.