4

The steps I follow for writing a video file in openCV are as follows:

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 writes at a fixed frame rate. I need to write out variable frame rate videos. The approach I had used earlier with libx264 involved writing individual timestamps to each frame.

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

Hrishikesh_Pardeshi
  • 995
  • 4
  • 19
  • 45

1 Answers1

1

I don't think it is possible to do this with OpenCV directly without modifying the code to give access under the hood. You would need to use a different library like libvlc to do so using the imem to get your raw RGB frames in OpenCV into a file. This link provides an example using imem with raw images loaded from OpenCV. You would just need to change the :sout options to save to the file you want using your preferred codec.

Community
  • 1
  • 1
bossbarber
  • 870
  • 6
  • 10