Ask Your Question
0

How can I save a video for a length of time?

asked 2017-01-30 21:09:33 -0600

j0h gravatar image

I have a video stream going, and object detection. If I detect an object, I want to stop detecting, save video for N seconds. I wrote a function, but its not right. After naming the file based on date and time, I'm not sure what to do. There is only 1 camera, and I am working on a linux system.

Should I close the existing video stream, then open another and save video for N seconds?

If I interrupt the video stream, I will get quality issues related to exposure, in the first few frames. Exposure settings are not supported on my camera in openCV.

I tried appending a stream and also tried saving a separate stream concurrently, but both resulted in problems.

Is there a preferred method to save parts of a video stream without interrupting the stream? if there is, can i get an example of that?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-31 03:09:49 -0600

LBerger gravatar image

updated 2017-01-31 20:41:34 -0600

I haven't try this program. I set fps to 20. TickMeter is available in opencv 3.2

struct VideoLimited {
VideoWriter f;
TickMeter t;
};

void main()
{
VideoLimited v;
v.f.open("myvideo.avi",videoWriter('M','J','P','G'),20,Size(640,480));
if (!v.f.isOpened())
   return;

v.t.start();
for (;;)
{
....

if (v.f.isOpened() && v.t.getTimeSec()<10) // I don't check  timing for video write...
    v.f.write(img);
else
    v.f.release();
...
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-30 21:09:33 -0600

Seen: 840 times

Last updated: Jan 31 '17