[FFmpeg-devel] [PATCH] Fix ID3v1 tags in mp3 files
James Darnley
james.darnley
Sat Jul 3 00:44:10 CEST 2010
When writing mp3 files, the metadata keys get converted to the ID3v2
tags. So if one tries to get a tag based on its generic name, the tag
won't be found, meaning that the ID3v1 comment will be filled with a
load of null bytes.
This patch changes what keys are searched for. Is it correct that the
conversion into format specific keys always uses the first matching
AVMetadataConv? Specifically, will "album" always become "TALB" with
the following?
{ "TALB", "album"},
{ "TAL", "album"},
-------------- next part --------------
>From cb61a1ec733af1cd12a549816237bfe4abc5c3dc Mon Sep 17 00:00:00 2001
From: James Darnley <james.darnley at gmail.com>
Date: Wed, 23 Jun 2010 21:32:43 +0200
Subject: [PATCH 3/5] Fix ID3v1 tags
The tag keys have been converted to the ID3v2 format so one must find them using those keys
---
libavformat/mp3.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavformat/mp3.c b/libavformat/mp3.c
index bdb2e4e..acb77dc 100644
--- a/libavformat/mp3.c
+++ b/libavformat/mp3.c
@@ -214,18 +214,18 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
buf[0] = 'T';
buf[1] = 'A';
buf[2] = 'G';
- count += id3v1_set_string(s, "title", buf + 3, 30);
- count += id3v1_set_string(s, "author", buf + 33, 30);
- count += id3v1_set_string(s, "album", buf + 63, 30);
- count += id3v1_set_string(s, "date", buf + 93, 4);
+ count += id3v1_set_string(s, "TIT2", buf + 3, 30); //title
+ count += id3v1_set_string(s, "TPE1", buf + 33, 30); //author
+ count += id3v1_set_string(s, "TALB", buf + 63, 30); //album
+ count += id3v1_set_string(s, "TDRL", buf + 93, 4); //date
count += id3v1_set_string(s, "comment", buf + 97, 30);
- if ((tag = av_metadata_get(s->metadata, "track", NULL, 0))) {
+ if ((tag = av_metadata_get(s->metadata, "TRCK", NULL, 0))) { //track
buf[125] = 0;
buf[126] = atoi(tag->value);
count++;
}
buf[127] = 0xFF; /* default to unknown genre */
- if ((tag = av_metadata_get(s->metadata, "genre", NULL, 0))) {
+ if ((tag = av_metadata_get(s->metadata, "TCON", NULL, 0))) { //genre
for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) {
buf[127] = i;
--
1.7.0.4
More information about the ffmpeg-devel
mailing list