Process Long Video Instantly (or quicker)

Hi. I’ve been writing a code that processes long videos. It works by performing a function on each individual frame. Say I wanted to return every frame that has a certain feature. Is there a way to instantly return these desired frames from a long video? I’m only able to process them at the speed of the video, so for long videos they take while to process.

if it’s a video file, you can try to parallelize it.
(from a webcam, not so)

Decoding and processing needs some time. If you have any imshow and waitKey in your loop you can remove that to speed things up, and as berak told, you can use multi-threading, but in the end, image processing is a more or less expensive task and you are processing a lot of frames.
If skipping (and therefore missing) frames isn’t an option…

video decoding is not constrained to “realtime playback” (unless gstreamer is involved in a way it shouldn’t be). video decoding can happen at hundreds to thousands of frames per second. decoders already use multithreading so you get that without doing anything special.

“instant” is physically impossible and “quicker than instant” is even more impossible :wink:

if you’re asking how to move back and forth to specific known frames inside a video, instead of decoding the whole video linearly, that’s called “seeking”, and OpenCV sucks at it (thanks to ffmpeg). for some video formats, it works okay, for others it’s buggy.

show us what exactly you did.