[FFmpeg-devel] flvdec.c

Atli Thorbjornsson atlithorn at gmail.com
Wed Feb 8 22:23:06 CET 2012


Hi all, I discovered a bug in flvdec.c where metadata frames that
occur right at the beginning of a stream are discarded. I hacked
together a little fix but I'm no FFMPEG expert so I dare say a more
elegant solution would be possible.

The problem lies in flv_read_packet. Here's the original source from
http://ffmpeg.org/doxygen/trunk/libavformat_2flvdec_8c-source.html#l00443

00481     } else if (type == FLV_TAG_TYPE_META) {
00482         if (size > 13+1+4 && dts == 0) { // Header-type metadata stuff
00483             flv_read_metabody(s, next);
00484             goto skip;
00485         } else if (dts != 0) { // Script-data "special" metadata
frames - don't skip
00486             stream_type=FLV_STREAM_TYPE_DATA;
00487         } else {
00488             goto skip;
00489         }
00490     }

This means that all packets at dts == 0 are basically discarded (goto
skip). In my case that means I miss out on important packets in the
beginning. My hack is just to allow the first packet to go to
flv_read_metabody but the rest return stream_type FLV_STREAM_TYPE_DATA
like all metadata packets that arrive later in the stream.

Like I said it's not elegant so I don't think it should be applied to
the source but I would be more than happy to code and return a
"proper" solution if someone pointed me in the right direction.
Anything that keeps me from having to maintain my own flvdec.c aside
from the source like I am currently forced to do.

Best regards,
Atli Thorbjornsson


More information about the ffmpeg-devel mailing list