Ask Your Question

Revision history [back]

Slow video write

Hi,

I have a very simple program where I iterate over a video frame by frame and draw a circle at a (x,y) coordinate and create a new video. For a 6 second video this takes anywhere from 8-12 seconds. Can some one suggest some way to speed up this process?

Else, suggest if there are other libraries which can do this simple task faster than open cv? I want to process a 45 seconds video in under 4 seconds. I have an i7 processor and want to execute this code in windows 10 using c++. My video file is in .avi format.

------------Code ------------

VideoCapture inputVideo(source);

VideoWriter outputVideo;

int ex = static_cast<int>(inputVideo.get(CAP_PROP_FOURCC));

outputVideo.open(NAME, ex, inputVideo.get(CAP_PROP_FPS), S, true);

... ... ...

Mat src;

for (;;) //Show the image captured in the window and repeat

{

    inputVideo >> src;              // read

    if (src.empty()) break;         // check if at end

    if (Ctr_vid > escape_frame - 1)
    {

        circle(src, Point(x_List[Ctr_frame], y_List[Ctr_frame]), 20, Scalar(150, 150, 150), 5, 8);
        Ctr_frame++;
    }
    Ctr_vid++;
    outputVideo << src;
}

Slow video write

Hi,

I have a very simple program where I iterate over a video frame by frame and draw a circle at a (x,y) coordinate and create a new video. For a 6 second video this takes anywhere from 8-12 seconds. Can some one suggest some way to speed up this process?

Else, suggest if there are other libraries which can do this simple task faster than open cv? I want to process a 45 seconds video in under 4 seconds. I have an i7 processor and want to execute this code in windows 10 using c++. My video file is in .avi format.

------------Code ------------

VideoCapture inputVideo(source); 

VideoWriter outputVideo;

outputVideo; int ex = static_cast<int>(inputVideo.get(CAP_PROP_FOURCC));

static_cast<int>(inputVideo.get(CAP_PROP_FOURCC)); outputVideo.open(NAME, ex, inputVideo.get(CAP_PROP_FPS), S, true);

... ... ...

true); Mat src;

src; for (;;) //Show the image captured in the window and repeat

repeat
{
  inputVideo >> src; // read
  if (src.empty()) break; // check if at end
  if (Ctr_vid > escape_frame - 1)
 {
  circle(src, Point(x_List[Ctr_frame], y_List[Ctr_frame]), 20, Scalar(150, 150, 150), 5, 8);
 Ctr_frame++;
 }
 Ctr_vid++;
  outputVideo << src;
 }