Is it possible to play videos backwards in OpenCV? Either by an API call or by buffering video frames and reversing the order into a new video file.
Thanks
The only practical way to do it is to manually extract frames, buffer them ( on memory or files) then reload them in reverse order.
The problem is that video compressors are all exploiting time redundancy - the fact that two consecutive frames are most of the time very similar. So, they encode a full frame from time to time (usually every few hundred frames) then only send differences between the previous and current.
Now, for decoding to work, it must be done in the same order - decode a keyframe (a full one), then for each new frame, add differences to obtain the current image.
This strategy makes it very hard to reverse play in video. There are several techniques, but all involve buffering.
Now, you may have seen the CV_CAP_PROP_POS_FRAMES parameters, described by Astor. It seems ok, but because of the issues described above, OpenCV is not able to correctly jump to a specific frame (there are multiple bugs open on these issues). They (OpenCV devs) are working on some solutions, but even those will be very slow (they involve going back to previous keyframe, then decoding back to the selected one). If you use this technique, each frame must be decoded hundreds of times on average, making it very slow. And yet, it doesn't work.
Edit If you pursue the buffer way to reverse it, keep in mind that a decoded video will quickly eat off the memory resources of a regular computer. A usual 720p video one minute long needs 4.7GB of memory when decompressed! Storing frames as individual files on disk is a practical solution to this problem.