ExternalVideoFrame
External video frame.
@JsonSerializable(explicitToJson: true, includeIfNull: false)
class ExternalVideoFrame {
const ExternalVideoFrame(
{this.type,
this.format,
this.buffer,
this.stride,
this.height,
this.cropLeft,
this.cropTop,
this.cropRight,
this.cropBottom,
this.rotation,
this.timestamp,
this.eglType,
this.textureId,
this.matrix,
this.metadataBuffer,
this.metadataSize,
this.alphaBuffer,
this.fillAlphaBuffer,
this.alphaStitchMode,
this.d3d11Texture2d,
this.textureSliceIndex,
this.colorSpace});
@JsonKey(name: 'type')
final VideoBufferType? type;
@JsonKey(name: 'format')
final VideoPixelFormat? format;
@JsonKey(name: 'buffer', ignore: true)
final Uint8List? buffer;
@JsonKey(name: 'stride')
final int? stride;
@JsonKey(name: 'height')
final int? height;
@JsonKey(name: 'cropLeft')
final int? cropLeft;
@JsonKey(name: 'cropTop')
final int? cropTop;
@JsonKey(name: 'cropRight')
final int? cropRight;
@JsonKey(name: 'cropBottom')
final int? cropBottom;
@JsonKey(name: 'rotation')
final int? rotation;
@JsonKey(name: 'timestamp')
final int? timestamp;
@JsonKey(name: 'eglType')
final EglContextType? eglType;
@JsonKey(name: 'textureId')
final int? textureId;
@JsonKey(name: 'matrix')
final List<double>? matrix;
@JsonKey(name: 'metadataBuffer', ignore: true)
final Uint8List? metadataBuffer;
@JsonKey(name: 'metadataSize')
final int? metadataSize;
@JsonKey(name: 'alphaBuffer', ignore: true)
final Uint8List? alphaBuffer;
@JsonKey(name: 'fillAlphaBuffer')
final bool? fillAlphaBuffer;
@JsonKey(name: 'alphaStitchMode')
final AlphaStitchMode? alphaStitchMode;
@JsonKey(name: 'd3d11Texture2d', readValue: readIntPtr)
final int? d3d11Texture2d;
@JsonKey(name: 'textureSliceIndex')
final int? textureSliceIndex;
@JsonKey(name: 'colorSpace')
final ColorSpace? colorSpace;
factory ExternalVideoFrame.fromJson(Map<String, dynamic> json) =>
_$ExternalVideoFrameFromJson(json);
Map<String, dynamic> toJson() => _$ExternalVideoFrameToJson(this);
}
Properties
- type
- Video type. See VideoBufferType.
- format
- Pixel format. See VideoPixelFormat.
- buffer
- Video buffer.
- stride
- Stride of the input video frame, in pixels (not bytes). For Texture, this refers to the width of the Texture.
- height
- Height of the input video frame.
- eglContext
- This parameter only applies to video data in Texture format.
- When using the OpenGL interface defined by Khronos (javax.microedition.khronos.egl.*), you need to assign
eglContextto this field. - When using the OpenGL interface defined by Android (android.opengl.*), you need to assign
eglContextto this field.
- When using the OpenGL interface defined by Khronos (javax.microedition.khronos.egl.*), you need to assign
- eglType
- This parameter only applies to video data in Texture format. Refers to the Texture ID of the video frame.
- textureId
- This parameter only applies to video data in Texture format. It is a 4x4 input transformation matrix, typically an identity matrix.
- matrix
- This parameter only applies to video data in Texture format. It is a 4x4 input transformation matrix, typically an identity matrix.
- metadataBuffer
- This parameter only applies to video data in Texture format. Refers to the data buffer of MetaData, default value is
NULL. - metadataSize
- This parameter only applies to video data in Texture format. Refers to the size of MetaData, default value is
0. - d3d11Texture2d
- This parameter only applies to video data in Windows Texture format. Represents a pointer to an object of type
ID3D11Texture2D, which is used by the video frame. - alphaBuffer
- Alpha channel data output by portrait segmentation algorithm. This data matches the size of the video frame. Each pixel value ranges from [0,255], where 0 represents background and 255 represents 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, make sure both the input video frame and
alphaBufferare of Full Range type; other types may cause incorrect rendering of alpha data. - fillAlphaBuffer
-
Note: For video data in BGRA or RGBA format, you can choose either method to set the alpha channel data:This parameter only applies to video data in BGRA or RGBA format. Sets whether to extract the alpha channel data from the video frame and automatically fill it into
- Automatically fill by setting this parameter to true.
- Set via the
alphaBufferparameter.
alphaBuffer:- true: Extract and fill alpha channel data.
- false: (default) Do not extract or fill alpha channel data.
- alphaStitchMode
- When the video frame contains alpha channel data, sets the relative position of
alphaBufferto the video frame. See AlphaStitchMode. - textureSliceIndex
- This parameter only applies to video data in Windows Texture format. Indicates the index of the
ID3D11Texture2Dtexture object used by the video frame in theID3D11Texture2Darray. - cropLeft
- This parameter only applies to raw video data.
- cropTop
- This parameter only applies to raw video data.
- cropRight
- This parameter only applies to raw video data.
- cropBottom
- This parameter only applies to raw video data.
- rotation
- Field related to raw data. Specifies whether to rotate the input video frame clockwise. Options are 0, 90, 180, 270. Default is 0.
- timestamp
- Timestamp of the input video frame, in milliseconds. Incorrect timestamps may cause frame drops or audio-video desynchronization.
- colorSpace
- Color space property of the video frame. By default, Full Range and BT.709 standard configuration is applied. You can customize the setting based on your custom capture or rendering requirements. See VideoColorSpace.