Callback Format

Description

A callback function is used to receive data (such as video frame data, ByteSize, and frame ID) encoded by VideoEncoder and implement user-defined processing functions in the callback.

To implement user-defined processing function, you are advised to perform operations, such as saving data and writing lists (append), to reduce the processing time and prevent the encoding thread from being blocked. Otherwise, the video encoding speed will slow down.

Prototype

1
def callback_func(pyBytes: bytes, outDataSize: int, channelId: int, frameId: int) -> None

Input Parameters

callback_func indicates the function name, which is user-defined but must be the same as the function name registered by registerVencCallBack.

Parameter

Type

Description

pyBytes

bytes

Output video frame data after encoding.

outDataSize

int

Memory size of the output video frame data after encoding.

channelId

int

Video stream index, which is set during VideoEncoder initialization.

frameId

int

Video frame index, which is set by the encode function of the VideoEncoder class.

If the callback function throws an exception, it triggers an exception on the C++ side, leading to a core dump. Capture and manage exceptions within the callback function.