Is there a way to encode a video so that forward and backward playback is very smooth? Is it possible in h264?
My understanding of the basic structure of the video encoding is that if the video is made of frames
f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 ...
that are encoded as
i1 d2 d3 d4 d5 i6 d7 d8 d9 d10 ...
i(k) == f(k), d(k) == f(k) - f(k-1)
i is an iframe and
d is a frame difference, so that the video size is much smaller that the size of all the images (frames) because deltas are smaller than entire frames. Then to get
f8, I've to stream and decode from the closest previous iframe
i6 and apply the deltas.
So the decoding/streaming cost per frame going forward is at most the cost of an iframe. But going backward, it can be much more. For instance if on
f6 I want to go to the previous frame
f5, I need to decode everything from the previous iframe
f1. Is there a way to encode things so that this doesn't happen, for instance by additionally storying the convenient (and somehow redundant) info
f6 - f5 ?
I'm familiar with ffmpeg and ideally would like to use it.
My use case is the following:
I'm streaming a video to a mobile client. The video is always paused and the user seeks back and forth through a slider. The backward seeking sometimes froze, and I believe it's when it's going through a keyframe and has to go back a lot and redecode to reach the previous frame. Forward seeking is fine.