VideoCapture -> Frames -> VideoCapture: Possible?
Hi!
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?
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 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.