VideoFrame
Video frame property settings.
public class VideoFrame
{
public VIDEO_PIXEL_FORMAT type;
public int width;
public int height;
public int yStride;
public int uStride;
public int vStride;
public byte[] yBuffer;
public IntPtr yBufferPtr;
public byte[] uBuffer;
public IntPtr uBufferPtr;
public byte[] vBuffer;
public IntPtr vBufferPtr;
public int rotation;
public long renderTimeMs;
public int avsync_type;
public IntPtr metadata_buffer;
public int metadata_size;
public IntPtr sharedContext;
public int textureId;
public IntPtr d3d11Texture2d;
public float[] matrix;
public byte[] alphaBuffer;
public ALPHA_STITCH_MODE alphaStitchMode;
public IVideoFrameMetaInfo metaInfo;
public ColorSpace colorSpace;
};
The buffer is a pointer to a pointer. This interface cannot modify the buffer pointer, only the buffer content.
Properties
- type
- Pixel format. See VIDEO_PIXEL_FORMAT.
- width
- Video pixel width.
- height
- Video pixel height.
- yStride
- For YUV data, indicates the 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 each row of pixel data according to this parameter, otherwise image distortion may occur.
- uStride
- For YUV data, indicates the stride of the U buffer; for RGBA data, the value is 0.
Note: When processing video data, you need to handle the offset between each row of pixel data according to this parameter, otherwise image distortion may occur.
- vStride
- For YUV data, indicates the stride of the V buffer; for RGBA data, the value is 0.
Note: When processing video data, you need to handle the offset between each row 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 null.
- vBuffer
- For YUV data, indicates the pointer to the V buffer; for RGBA data, the value is null.
- rotation
- Set 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 the rendering of the video frame. This parameter is required.
- avsync_type
- Reserved parameter.
- metadata_buffer
- This parameter is only applicable to video data in Texture format. Refers to the metadata buffer. The default value is
NULL. - metadata_size
- This parameter is only applicable to video data in Texture format. Refers to the size of the metadata. The default value is
0. - sharedContext
- This parameter is only applicable to video data in Texture format. EGL Context.
- textureId
- This parameter is only applicable to video data in Texture format. Texture ID.
- d3d11Texture2d
- This parameter is only applicable to video data in Windows Texture format. Represents a pointer to an object of type
ID3D11Texture2D, which is used by the video frame. - matrix
- This parameter is only applicable to video data in Texture format. It is an input 4x4 transformation matrix, typically 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 the settings based on your custom capture and rendering requirements. 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
alphaBufferare of Full Range type; other types may cause abnormal Alpha data rendering. - Make sure that
alphaBufferexactly matches the size of the video frame (width × height), otherwise the app may crash.
- In custom video rendering scenarios, ensure that both the video frame and
- alphaStitchMode
- When the video frame contains Alpha channel data, sets the relative position of
alphaBufferand the video frame. See ALPHA_STITCH_MODE. - metaInfo
- Metadata in the video frame. This parameter requires contacting technical support for use.