[英]Writing variable framerate videos in openCV
The steps I follow for writing a video file in openCV are as follows: 我在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 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.
我之前使用libx264的方法涉及将每个时间戳写入每个帧。
So, the question is how do I write timestamps to a frame in openCV - what is the specific API ? 那么,问题是我如何在openCV中向一个帧写入时间戳 - 具体的API是什么? More generally, how do I create variable frame rate videos ?
更一般地说,如何创建可变帧速率视频?
I don't think it is possible to do this with OpenCV directly without modifying the code to give access under the hood. 我不认为可以直接使用OpenCV进行此操作而无需修改代码以提供访问权限。 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.
您需要使用不同的库(如libvlc)才能使用imem将OpenCV中的原始RGB帧放入文件中。 This link provides an example using imem with raw images loaded from OpenCV.
此链接提供了一个使用imem和从OpenCV加载的原始图像的示例。 You would just need to change the :sout options to save to the file you want using your preferred codec.
您只需要使用首选编解码器更改:sout选项以保存到您想要的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.