[FFmpeg-devel] [PATCH] common ID3v2 support for all formats
Reimar Döffinger
Reimar.Doeffinger
Wed Nov 3 23:05:41 CET 2010
On Wed, Nov 03, 2010 at 10:40:30PM +0100, Anton Khirnov wrote:
> On Fri, Oct 01, 2010 at 08:21:07PM +0200, Reimar D?ffinger wrote:
> > Hello,
> > considering issue 2258 I think it is a valid conclusion that people
> > will prepend a ID3v2 header to anything that can't run aways fast enough
> > (and then give it a .mp3 extension...).
> > So I propose attached patch that moves that parsing to common code.
> > Note that is assume that due to buffering the ID3 parsing attempt
> > will not cause any issues even on non-seekable input.
> > Note that I have no idea WTF the mpc demuxer code is doing there,
> > my conclusion was that it should be safe to just throw it all away,
> > but I'm not 100% sure I don't miss some subtlety.
> > Mostly unrelated, but one issue with this whole ID3 handling is
> > that AFAICT it will use the file-specific metadata conversion
> > instead of using always the ID3 one.
> This change broke detection of mp3 files with really big id3v2 headers
> in MPD, which uses a small 64kb buffer. This is probably MPD's fault,
> but perhaps there should be a way for av_probe_input_format to signal
> that "the stream looks useful, need more data" -- which would be done e.g.
> when an id3 header is found which is bigger than the probe data buffer.
I'd suggest to just set score_max, something like below.
Of course doesn't work so well for anyone calling it with
*score_max == AVPROBE_SCORE_MAX/4 from the start.
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 25668)
+++ libavformat/utils.c (working copy)
@@ -353,13 +353,15 @@
AVProbeData lpd = *pd;
AVInputFormat *fmt1, *fmt;
int score;
+ int found_incomplete_id3v2 = 0;
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
int id3len = ff_id3v2_tag_len(lpd.buf);
if (lpd.buf_size > id3len + 16) {
lpd.buf += id3len;
lpd.buf_size -= id3len;
- }
+ } else
+ found_incomplete_id3v2 = 1;
}
fmt = NULL;
@@ -380,6 +382,8 @@
}else if (score == *score_max)
fmt = NULL;
}
+ if (!fmt && found_incomplete_id3v2)
+ *score_max = FFMAX(*score_max, AVPROBE_SCORE_MAX/4);
return fmt;
}
More information about the ffmpeg-devel
mailing list