record with desired fps [closed]
I am reading a video from a file (which later I'll replace with live video from a camera). I am using videocapture to read frames and videowriter to write to a file.
Now I want to write to file with a certain FPS(I am trying to make a timelapse video). Upon using FPS value of videowriter it just displays the same video with given FPS.
VideoWriter videoTimelapse;
void recordTimelapse(Mat frame_timelapse)
{
if (!videoTimelapse.isOpened())
{
videoTimelapse.open("/home/Anurag_Workspace/Timelapse_Video.avi",CV_FOURCC('M','J','P','G'),FPS_TIMELAPSE, Size(MAX_WIDTH,MAX_HEIGHT));
}
videoTimelapse.write(frame_timelapse);
}
For eg. if I have a 1minute long video and FPS is set as 5, it just makes the video 4-5mins long and displays it with lower FPS( with almost same size on disk). Whereas I want it to read from videoCapture every .2 seconds and make a video out of that. Which should obviously be lower in size and length.
A videoCapture
is running in a while(1)
loop in main.c which sends the current frame to 4 functions, one of them is recordTimelapse
.
opencv is a computer-vision library. VideoCapture / Writer are (quite dumb) utilities to acquire images for that.
if you want to build video editing software, please use something else.