1. Hardcoding in OpenCV
In OpenCV2.4.6, the use of GPU to write video has been implemented. The encoding process is completed by cv::gpu::VideoWriter_GPU . The sample program is as follows.
Deeply read the implementation of the cv::gpu::VideoWriter_GPU class, and found that its underlying encoding implementation is based on the NVCUVENC library, and the video file package is FFmpeg. 2. NVCUVENC library The NVCUVENC library is a video encoding library provided by NVIDIA, which can implement H.264 GPU encoding, receive raw YUV frames data, and encode to generate NAL packets. The basic steps for video hardcoding using the NVCUVENC library are as follows: 1. Check whether NVCUVENC is supported 2. Create a new encoder and set the encoding type 3. Set the encoding parameters and register the callback function 4. Create encoder related resources 5. Loop encoding each frame of data 6. Delete the encoder and release resources The pseudo-code schematic diagram is shown below, in which the allocation of buffers before encoding and the processing of data after encoding are all performed by callback functions. Callback function description: AcquireBitstream() allocates a coded bitstream buffer ReleaseBitstream() process and save coded bitstream OnBeginFrame() initialization work before encoding
OnEndFrame() encoded statistical work
The calling sequence of the callback function: |
The article is reproduced from: Rosso Lab [] Source of this article: Blog Park Author: dwdxdy original text |