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

Kharkov Alexander kharkovalexander at gmail.com
Fri Apr 8 11:20:45 CEST 2011


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.

On 1 April 2011 19:00, Michael Niedermayer <michaelni at gmx.at> wrote:
> Hi
>
> On Thu, Mar 03, 2011 at 11:35:27AM +0600, Kharkov Alexander wrote:
>> Can someone review and probably apply the patch?
>
> Iam sorry for the delay, the patch has been applied with cleanups
> to ffmpeg.
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The bravest are surely those who have the clearest vision
> of what is before them, glory and danger alike, and yet
> notwithstanding go out to meet it. -- Thucydides
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk2Vvm8ACgkQYR7HhwQLD6t4sQCgkzLMBEyqIb1gpwG62yz0b11g
> vLUAoItL9VMR/OiziQqM9/LqOhaAZP4A
> =Mkf+
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flvdec.c.git.diff
Type: text/x-patch
Size: 767 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110408/51f68514/attachment.bin>


More information about the ffmpeg-devel mailing list