VideoFrame
Properties of a video frame.
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 a pointer to a pointer. This interface cannot modify the pointer of the buffer, only its contents.
Properties
- type
- Pixel format. See VideoPixelFormat.
- width
- Video pixel width.
- height
- Video pixel height.
- yStride
- For YUV data, the stride of the Y buffer; for RGBA data, the total data length.
Note: When processing video data, use this parameter to handle the offset between rows of pixel data. Otherwise, image distortion may occur.
- uStride
- For YUV data, the stride of the U buffer; for RGBA data, the value is 0.
Note: When processing video data, use this parameter to handle the offset between rows of pixel data. Otherwise, image distortion may occur.
- vStride
- For YUV data, the stride of the V buffer; for RGBA data, the value is 0.
Note: When processing video data, use this parameter to handle the offset between rows of pixel data. Otherwise, image distortion may occur.
- yBuffer
- For YUV data, the pointer to the Y buffer; for RGBA data, the data buffer.
- uBuffer
- For YUV data, the pointer to the U buffer; for RGBA data, the value is empty.
- vBuffer
- For YUV data, the pointer to the V buffer; for RGBA data, the value is empty.
- rotation
- Clockwise rotation angle to apply before rendering the video. Supported values: 0, 90, 180, and 270 degrees.
- renderTimeMs
- Unix timestamp (ms) when the video frame is rendered. This timestamp is required and guides the rendering of the video frame.
- avsync_type
- Reserved parameter.
- metadata_buffer
- Applicable only to Texture format video data. Metadata buffer. Default is
NULL. - metadata_size
- Applicable only to Texture format video data. Metadata size. Default is
0. - textureId
- Applicable only to Texture format video data. Texture ID.
- matrix
- Applicable only to Texture format video data. A 4x4 transformation matrix input. Typical value is an identity matrix.
- colorSpace
- Color space attributes of the video frame. By default, Full Range and BT.709 standard configurations are applied. You can customize this according to custom capture or rendering needs. See VideoColorSpace.
- alphaBuffer
- Alpha channel data output by portrait segmentation algorithm. This data matches the video frame dimensions. Each pixel value ranges from [0, 255], where 0 represents background and 255 represents foreground (portrait).
You can use this parameter to render various background effects such as transparent, solid color, image, or video.
Note:
- In custom video rendering scenarios, ensure both the video frame and
alphaBufferare Full Range type; other types may cause rendering issues. - Make sure
alphaBuffermatches the video frame dimensions (width × height) exactly, otherwise the app may crash.
- In custom video rendering scenarios, ensure both the video frame and
- alphaStitchMode
- When the video frame includes alpha channel data, sets the relative position of
alphaBufferand the video frame. See AlphaStitchMode. - metaInfo
- Metadata in the video frame. Contact technical support to use this parameter.