[FFmpeg-devel] [PATCH] libavformat/id3v2: Read full null seperated list for text info frames
Lode Willems
me at lodewillems.com
Wed Apr 7 02:22:30 EEST 2021
All id3v2.4 text information frames are null separated lists:
https://id3.org/id3v2.4.0-frames
This change reads all values into the metadata dictionary without changing the
outputs of ffmpeg or ffprobe
Relevant ticket: https://trac.ffmpeg.org/ticket/6949
Signed-off-by: Lode Willems <me at lodewillems.com>
---
libavformat/id3v2.c | 5 ++++-
libavformat/metadata.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 863709abbf..9ef56a52c2 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -320,7 +320,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen,
AVDictionary **metadata, const char *key)
{
uint8_t *dst;
- int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL;
+ int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL | AV_DICT_MULTIKEY;
unsigned genre;
if (taglen < 1)
@@ -329,6 +329,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen,
encoding = avio_r8(pb);
taglen--; /* account for encoding type byte */
+ /* Read all null-terminated values */
+ while (taglen > 0) {
if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
av_log(s, AV_LOG_ERROR, "Error reading frame %s, skipped\n", key);
return;
@@ -353,6 +355,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen,
if (dst)
av_dict_set(metadata, key, dst, dict_flags);
+ }
}
static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen,
diff --git a/libavformat/metadata.c b/libavformat/metadata.c
index b9b6de7972..68382e7937 100644
--- a/libavformat/metadata.c
+++ b/libavformat/metadata.c
@@ -50,7 +50,7 @@ void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
key = dc->native;
break;
}
- av_dict_set(&dst, key, mtag->value, 0);
+ av_dict_set(&dst, key, mtag->value, AV_DICT_DONT_OVERWRITE);
}
av_dict_free(pm);
*pm = dst;
--
2.31.0
More information about the ffmpeg-devel
mailing list