Question

I am reading a video file using DataInputStream. I am then using a byte array to read data one by one for each frame and then displaying them consecutively. My question is, what if I wanted to see a previous frame again, or a future frame for that matter? Is it possible to step back in the stream, or is any other way possible?

Was it helpful?

Solution

I would use a memory mapped approach for this. If you know what the size of each frame is, and it's fixed, there is no reason why you can skip (forward/backwards) and simply map in that frame (or sequence of frames).

OTHER TIPS

As a "simple" solution, you could wrap your DataInputStream with a PushbackInputStream. However I wouldn't rely on that, but write my own buffering strategy. Why don't you just cache the last frame in memory?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top