[Libav-user] Speeding video decoding

Anton Shekhovtsov shekh.anton at gmail.com
Sun Jun 21 20:20:27 CEST 2015


2015-06-21 20:26 GMT+03:00 Don Moir <donmoir at comcast.net>:


> Hi Gonzalo,
>
> You can try to set skip_loop_filter to AVDISCARD_NONREF and there could be
> some other flags you can set to speed things up just slightly. decoding can
> be intense and probably the slowest thing you need to deal with.
>
> For scrubbing though, I am thinking you don't need to decode every single
> frame. For example, if video is at 25 FPS, it may be you could get away
> with like 10 FPS or less. When user is scrubbing it is not likely you would
> be able to display every frame anyway.
>
> I am also interested in this and have not yet investigated it so I would
> be interested in what you come up with.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>


I have implemented this. The best approach to performance depends on codec.
But if we are talking about something like avc with reasonable keyframe
interval (order of 100), I came up with this:
1) If I can reach desired frame by decoding forward less than ~100 frames,
I just decode all these frames (even if most of them are already cached).
2) Every decoded frame is cached within window of 2*keyframe interval frames
3) If I need to go backward, I seek to previous keyframe and decode
everything forward until desired frame (and cache all decoded frames)
4) If I can go backward and all frames until previous key are already
cached, I speculatively decode frames which are further away.
This way if I move sequentially (backward or forward), for each frame step
there is exactly one frame decode. The frame cache allows to hide the fact
that frames are always decoded forward while you request them backward.

Then there are other tiny details with seeking. To perform it realistically
you best deal with single stream at a time (multistream seeking is really
not designed for scrubbing). And you have to have proper keyframe index to
know how to seek to keyframes and measure distances.

You can check how it works within virtualdub, there is source code
 https://sourceforge.net/projects/vdcachingdriver/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150621/2b5434e2/attachment.html>


More information about the Libav-user mailing list