VideoCapture -> Frames -> VideoCapture: Possible?

asked 2016-11-11 14:07:49 -0600

vidark gravatar image

updated 2019-12-09 08:06:31 -0600

Akhil Patel gravatar image


I want to extract a few very specific frames out of a VideoCapture Stream that has been created from a file.

Everytime I extract a frame however, I want to feed it back into another VideoCapture, for two reasons:

  • VideoCapture's make it really easy to navigate through a video and read invidual frames.
  • Performance: Video's are big, frames are too. If I were to keep every single of the uncompressed frames in memory, the memory could easily run out on slower machines. I've thought about temporarily saving every frame to a file and only reading one frame at a time when I need it, but it seems kind of clumsy. Same with writing every of these frames to a VideoWriter (So, save the frames as a video) only to read them in once again - Especially because I'd probably lose a lot of accuracy, seeing how they'll get decoded and encoded multiple times.

What do you think should I do?

edit retag flag offensive close merge delete



I don't understand your question so much. If your input feed is always faster than your processing thread you will run out of mem sooner or later. Doesn't matter of machine speed or available memory, theoretically you might full up the hard disk too. BTW if you like to store frames using VideoWriter you could use some lossless codec.

pklab gravatar imagepklab ( 2016-11-13 12:35:08 -0600 )edit

@pklab It's not about whether the feed is faster than the processing or not. I don't care very much about speed. I have an input video file, which consists of x frames. What I now want to have is another VideoCapture object with only very specific frames that have been chosen by an algorithm by looping through the first VideoCapture. Basically, I have a list of frames, and I want them to be accessible in a handy way by having them in a videocapture.

vidark gravatar imagevidark ( 2016-11-13 14:00:40 -0600 )edit