Ask Your Question

Revision history [back]

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)
    v.f.write(img);
else
    v.f.release();
...
}

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)
v.t.getTimeSec()<10) // I don't check  timing for video write...
    v.f.write(img);
else
    v.f.release();
...
}