[FFmpeg-devel] [PATCH] support for flvtool2 "keyframes based" generated index in FLV format decoder

Michael Niedermayer michaelni at gmx.at
Sat Apr 9 00:04:47 CEST 2011


On Fri, Apr 08, 2011 at 04:20:45PM +0700, Kharkov Alexander wrote:
> Thanks, Michael
> I just checkout this changes.
> Actually committed patch have rare noticeable but very unpleasant bug
> which were not present in original sent patch.
> 
> Current keyframes data parser unconditionally rewind metadata to the end
> at the end of function. As result ALL metadata located after keyframes
> index not parsed,
> and as metadata object can have ANY placement inside metadata it can
> lead to unpredictable result
> (bitrate can not be found, etc.). As result FLV movie will not play at
> all in such situation.
> 
> static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
> AVStream *vstream, int64_t max_pos) {
> ...
>   avio_seek(ioc, max_pos, SEEK_SET);
> }
> Here max pos is the END of all metadata not keyframes object.
> There are no normal way in FLV format to determine where object end is
> located except loop over all embeded object
> (this is default metadata parser behavior in flvdec.c).
> To fix it I suggest following: rewind metadata stream to initial
> keyframes position after this object is parsed and default parser
> will continue parse all metadata as usual.
> So proposed fix will looks like following:
> 
> static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
> AVStream *vstream, int64_t max_pos) {
>   int64_t initial_pos = url_ftell(ioc);
> ...
>   avio_seek(ioc, initial_pos, SEEK_SET);
>                        ^^^^^^^^^^^^^
> }
> I've attached patch just in case.

thanks
patch applied
i also added a seekable check as the seek back could cause problems
otherwise

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110409/23899adb/attachment.asc>


More information about the ffmpeg-devel mailing list