[FFmpeg-user] Most efficient format/container for seeking

Robert Krüger krueger at lesspain.de
Sun Sep 1 16:03:11 CEST 2013


On Sun, Sep 1, 2013 at 3:38 PM, Maxim E <maxoumdu35 at gmail.com> wrote:
> Hi,
>
> This question will probably be best answered by developpers themselves, I'm
> looking for the most efficient container for seeking.
>
> My problem :
> I'm downloading a video file that eventually gets very large, and seeking
> can take a lot of time. I guess the whole file is processed until the right
> frame is found. Is there any container with which the seeking process is
> more "optimized" ?
> For instance, instead of processing the whole file, the total duration of
> the video is calculated somehow, and the file size is used to look at some
> position (if the framerate is constant).
>
> An example to make myself clear :
> I've got a 20 Gb file, in a FLV container. No problem to get the total
> duration, ffmpeg -i file.flv returns it in just a few seconds (Duration:
> 55:07:28.35).
> No problem when I seek to the beginning of the file, for example "ffmpeg
> -ss 00:02:00.00 -i file.flv -t 10 -c:a copy -c:v copy out.flv" gets
> executed in a few seconds. However, "ffmpeg -ss 10:02:00.00 -i file.flv -t
> 10 -c:a copy -c:v copy out.flv" takes at least one minute, which makes me
> think ffmpeg process the file from the beginning until it finds the
> matching frame.
> Let's consider the framerate is constant
> 20 000 Mo x 10 Hours / 55 Hours should return the approximate position at
> which the frame that is sought is, and starting from there instead of
> starting from the beginning of the file would make things much more
> efficient. Is there such a container that supports this type of seeking ?
> Or is it impossible ? I don't have much experience with development/media
> files so maybe things are not as easy as I think, but please let me know !

mp4 and mov both support what you are looking for. They contain
metadata where each frame and packet of sound samples is located in
the file. You can additionally force that metadata at the beginning of
the file by using the option -movflags faststart, if you have
situations where you want to seek based on only a partially downloaded
file, which is what many players support.


More information about the ffmpeg-user mailing list