Recording video with variable frame rate in openCV

The following are the steps that I follow to record a video file in openCV:

CvVideoWriter *writer =cvCreateVideoWriter(fileName, Codec ID, frameRate, frameSize); // Create Video Writer cvWriteFrame(writer, frame); // Write frame cvReleaseVideoWriter(&writer); // Release video writer 

The above code snippet is recorded at a fixed frame rate. I need to record a video with a variable frame rate. The approach I used earlier with libx264 included writing separate timestamps to each frame.

So the question is how to write timestamps for a frame in openCV - what is a specific API? More generally, how do I create a video with a variable frame rate?

+4
source share
1 answer

I do not think that this can be done directly with OpenCV, without changing the code to access the hood. You will need to use another library like libvlc to do this with imem to get your raw RGB frames in OpenCV into a file. This link provides an example of using imem with raw images downloaded from OpenCV. You just need to change the parameters: sout to save the file you want using your preferred codec.

+1
source

Source: https://habr.com/ru/post/1487847/


All Articles