mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-03 11:07:41 +00:00
lavf/mp3enc: fix ID3v1 year metadata setting issue
Follow the http://id3.org/ID3v1, setting the year metadata for ID3v1. fix #8623 Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
parent
a9029703bb
commit
280383a897
@ -45,6 +45,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key,
|
|||||||
return !!tag;
|
return !!tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// refer to: http://id3.org/ID3v1
|
||||||
static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
|
static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
|
||||||
{
|
{
|
||||||
AVDictionaryEntry *tag;
|
AVDictionaryEntry *tag;
|
||||||
@ -58,7 +59,17 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
|
|||||||
count += id3v1_set_string(s, "TIT2", buf + 3, 30 + 1); //title
|
count += id3v1_set_string(s, "TIT2", buf + 3, 30 + 1); //title
|
||||||
count += id3v1_set_string(s, "TPE1", buf + 33, 30 + 1); //author|artist
|
count += id3v1_set_string(s, "TPE1", buf + 33, 30 + 1); //author|artist
|
||||||
count += id3v1_set_string(s, "TALB", buf + 63, 30 + 1); //album
|
count += id3v1_set_string(s, "TALB", buf + 63, 30 + 1); //album
|
||||||
count += id3v1_set_string(s, "TDRC", buf + 93, 4 + 1); //date
|
if ((tag = av_dict_get(s->metadata, "TYER", NULL, 0))) { //year
|
||||||
|
av_strlcpy(buf + 93, tag->value, 4 + 1);
|
||||||
|
count++;
|
||||||
|
} else if ((tag = av_dict_get(s->metadata, "TDRC", NULL, 0))) {
|
||||||
|
av_strlcpy(buf + 93, tag->value, 4 + 1);
|
||||||
|
count++;
|
||||||
|
} else if ((tag = av_dict_get(s->metadata, "TDAT", NULL, 0))) {
|
||||||
|
av_strlcpy(buf + 93, tag->value, 4 + 1);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
count += id3v1_set_string(s, "comment", buf + 97, 30 + 1);
|
count += id3v1_set_string(s, "comment", buf + 97, 30 + 1);
|
||||||
if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
|
if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
|
||||||
buf[125] = 0;
|
buf[125] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user