[Libav-user] How do I seek to the very beginning of a file?

Michael Bradshaw mbradshaw at sorensonmedia.com
Wed Oct 17 02:26:20 CEST 2012


On Tue, Oct 16, 2012 at 5:10 PM, Don Moir <donmoir at comcast.net> wrote:
> I use avformat_seek_file and so does ffplay etc. I always use a valid stream
> index and not -1. I don't leave it up to ffmpeg to determine what stream to
> seek on.
>
> I always take the first_dts for the stream into account. The first_dts will
> be the zero mark for the stream. first_dts can be zero, less than zero, or
> greater than zero.
>
> I use AVSEEK_FLAG_BACKWARD (regardless if seeking to zero or not).
>
> With above logic, I can't remember the last time I had a problem seeking to
> zero (first_dts).
>
> Should I have to do the above ?  probably not...

Ugh, seems complex. It's complicated by the fact that not all formats
seek by DTS (some seek by PTS, like nut). I may have to do that, but
I'm hoping there's a better alternative... Heck, even seeking by byte
to the first packet position seems preferable (though I can't see why
seeking to a byte index of 0 shouldn't work). It's not that the above
is super complex and overly hard... it's just that for such a basic,
frequently used operation (seeking to the beginning), it seems...
wrong.

> Also not to say there isn't a few problem files here and there but these
> just need to be reported so it can be fixed.
>
> Do you have a particular file that is a problem and can be posted ?

I've got a bunch of files that seem to completely ignore
AVSEEK_FLAG_BYTE and seeking to 0, despite returning "success." I can
also write some sample code if needed to demonstrate. Shall I?

Thanks,

Michael


More information about the Libav-user mailing list