[Ffmpeg-devel] [PATCH] Fix broken flv seeking

Michael Niedermayer michaelni
Sun Dec 17 17:01:44 CET 2006


Hi

On Sun, Dec 17, 2006 at 11:45:21PM +0900, nazo wrote:
> >rejected
> >* this duplicates alot of code
> I think that this is needed.
> >* this simply reads through the whole file = O(n) complexity
> now read only different indexes.
> >* its identical to av_build_index_raw() just not as generic
> >* implement AVCodec.read_timestamp() or write your own O(log n) seek
> >  if you prefer and its small simple and clean
> I don't know how to write O(log n) seek for flv demuxer. flv packet is 
> not fixing size.

each flv packet contains a 24bit size and a 32bit size of the previous
packet (the high 8 bit must be 0 ...) and 8bit flags, with these alone
you have a 2^16 : 1 chance of missdetecting a frame, now if you follow
the size to the next and previous headers and check that they are valid
too and have matching sizes then you have something like 2^(3*15+2*24):1 
or so chance of missdetecting a framestart, if thats still not enough just
check another frame more, at some point it will be more likely that the
hardware will fail then the frame detection so i would say a O(log n)
binary search is not hard wth flv
just implement AVCodec.read_timestamp()

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch




More information about the ffmpeg-devel mailing list