You can implement video decoding by constructing an instance of the VideoDecoder class. For details about the decoding configuration items and restrictions, see VideoDecodeConfig.
Video decoding supports customized output data formats. You can use a customized callback function to input the decoding configuration items to use the decoded data. For details, see VideoDecodeCallBack.
For details about video decoding APIs, see VideoDecoder.
Define the output data combination mode as required, refer to VideoDecodeCallBack to define the callback function, and input decoding configuration items. Instantiate the VideoDecoder class, and call the member function of Decode to complete decoding and obtain data.
Process of calling APIs of video decoding is as follows:

Vision SDK provides the VideoDecoder class for video decoding. The key steps are described as follows:
For details about the configuration items and restrictions, see the data structure description of VideoDecodeConfig.
Input the configured VideoDecodeConfig to the constructor API to instantiate the video decoding class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | // Initialization MxBase::MxInit(); { // Define the decoded data to be received. struct FrameImage { Image image; // Video frame object uint32_t frameId = 0; // Video frame ID uint32_t channelId = 0; // Video processing channel ID }; // Define the callback function for transferring the decoded data to the customized structure. APP_ERROR CallBackVdec(Image& decodedImage, uint32_t channelId, uint32_t frameId, void* userData) { FrameImage* decodedVec = static_cast<FrameImage*>(userData); decodedVec->image = decodedImage; decodedVec->channelId = channelId; decodedVec->frameId = frameId; } // Construct the decoding configuration items. MxBase::VideoDecodeConfig config; VideoDecodeCallBack cPtr = CallBackVdec; config.width = 1920; config.height = 1080; config.callbackFunc = cPtr; config.skipInterval = 0; config.inputVideoFormat = StreamFormat::H264_MAIN_LEVEL; config.outputImageFormat = ImageFormat::YUV_SP_420; // Instantiate the decoding class. MxBase::VideoDecoder videoDecoder(config, deviceId, channelId); // Perform the decoding operation. ret = videoDecoder.Decode(dataPtr, dataSize, frameId, &decodedFrame); } // Deinitialization MxBase::MxDeInit(); |