You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat: Ignore ID3v2 tags if other tags are present e.g. vorbis
Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
dce863421b
commit
65862f57ad
@@ -140,6 +140,11 @@ struct AVFormatInternal {
|
|||||||
* Whether or not avformat_init_output fully initialized streams
|
* Whether or not avformat_init_output fully initialized streams
|
||||||
*/
|
*/
|
||||||
int streams_initialized;
|
int streams_initialized;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID3v2 tag useful for MP3 demuxing
|
||||||
|
*/
|
||||||
|
AVDictionary *id3v2_meta;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AVStreamInternal {
|
struct AVStreamInternal {
|
||||||
|
@@ -349,6 +349,9 @@ static int mp3_read_header(AVFormatContext *s)
|
|||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
s->metadata = s->internal->id3v2_meta;
|
||||||
|
s->internal->id3v2_meta = NULL;
|
||||||
|
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
@@ -588,12 +588,26 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
|
|||||||
|
|
||||||
/* e.g. AVFMT_NOFILE formats will not have a AVIOContext */
|
/* e.g. AVFMT_NOFILE formats will not have a AVIOContext */
|
||||||
if (s->pb)
|
if (s->pb)
|
||||||
ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, 0);
|
ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
|
||||||
|
|
||||||
|
|
||||||
if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
|
if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
|
||||||
if ((ret = s->iformat->read_header(s)) < 0)
|
if ((ret = s->iformat->read_header(s)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
if (!s->metadata) {
|
||||||
|
s->metadata = s->internal->id3v2_meta;
|
||||||
|
s->internal->id3v2_meta = NULL;
|
||||||
|
} else if (s->internal->id3v2_meta) {
|
||||||
|
int level = AV_LOG_WARNING;
|
||||||
|
if (s->error_recognition & AV_EF_COMPLIANT)
|
||||||
|
level = AV_LOG_ERROR;
|
||||||
|
av_log(s, level, "Discarding ID3 tags because more suitable tags were found.\n");
|
||||||
|
av_dict_free(&s->internal->id3v2_meta);
|
||||||
|
if (s->error_recognition & AV_EF_EXPLODE)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
if (id3v2_extra_meta) {
|
if (id3v2_extra_meta) {
|
||||||
if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
|
if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
|
||||||
!strcmp(s->iformat->name, "tta")) {
|
!strcmp(s->iformat->name, "tta")) {
|
||||||
@@ -4178,6 +4192,7 @@ void avformat_free_context(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
av_freep(&s->chapters);
|
av_freep(&s->chapters);
|
||||||
av_dict_free(&s->metadata);
|
av_dict_free(&s->metadata);
|
||||||
|
av_dict_free(&s->internal->id3v2_meta);
|
||||||
av_freep(&s->streams);
|
av_freep(&s->streams);
|
||||||
av_freep(&s->internal);
|
av_freep(&s->internal);
|
||||||
flush_packet_queue(s);
|
flush_packet_queue(s);
|
||||||
|
Reference in New Issue
Block a user