diff mbox series

[FFmpeg-devel,v1] lavf/mp3enc: fix ID3v1 year metadata setting issue

Message ID 1587370626-13401-1-git-send-email-mypopydev@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v1] lavf/mp3enc: fix ID3v1 year metadata setting issue | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Jun Zhao April 20, 2020, 8:17 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

Follow the http://id3.org/ID3v1, setting the year metadata
for ID3v1.

fix #8623

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/mp3enc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Anton Khirnov April 20, 2020, 11:59 a.m. UTC | #1
Quoting Jun Zhao (2020-04-20 10:17:06)
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> Follow the http://id3.org/ID3v1, setting the year metadata
> for ID3v1.
> 
> fix #8623
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/mp3enc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
> index 34b753f..157174f 100644
> --- a/libavformat/mp3enc.c
> +++ b/libavformat/mp3enc.c
> @@ -45,6 +45,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key,
>      return !!tag;
>  }
>  
> +// refer to: http://id3.org/ID3v1
>  static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
>  {
>      AVDictionaryEntry *tag;
> @@ -58,7 +59,7 @@ 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, "TPE1",    buf + 33, 30 + 1);       //author|artist
>      count += id3v1_set_string(s, "TALB",    buf + 63, 30 + 1);       //album
> -    count += id3v1_set_string(s, "TDRC",    buf + 93,  4 + 1);       //date
> +    count += id3v1_set_string(s, "TYER",    buf + 93,  4 + 1);       //year

This will break for ID3v2.4, no?
mypopy@gmail.com April 20, 2020, 12:05 p.m. UTC | #2
On Mon, Apr 20, 2020 at 8:00 PM Anton Khirnov <anton@khirnov.net> wrote:
>
> Quoting Jun Zhao (2020-04-20 10:17:06)
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > Follow the http://id3.org/ID3v1, setting the year metadata
> > for ID3v1.
> >
> > fix #8623
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavformat/mp3enc.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
> > index 34b753f..157174f 100644
> > --- a/libavformat/mp3enc.c
> > +++ b/libavformat/mp3enc.c
> > @@ -45,6 +45,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key,
> >      return !!tag;
> >  }
> >
> > +// refer to: http://id3.org/ID3v1
> >  static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
> >  {
> >      AVDictionaryEntry *tag;
> > @@ -58,7 +59,7 @@ 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, "TPE1",    buf + 33, 30 + 1);       //author|artist
> >      count += id3v1_set_string(s, "TALB",    buf + 63, 30 + 1);       //album
> > -    count += id3v1_set_string(s, "TDRC",    buf + 93,  4 + 1);       //date
> > +    count += id3v1_set_string(s, "TYER",    buf + 93,  4 + 1);       //year
>
> This will break for ID3v2.4, no?
>
Why? This change is just changing the ID3v1
> --
> Anton Khirnov
Anton Khirnov April 20, 2020, 12:11 p.m. UTC | #3
Quoting mypopy@gmail.com (2020-04-20 14:05:50)
> On Mon, Apr 20, 2020 at 8:00 PM Anton Khirnov <anton@khirnov.net> wrote:
> >
> > Quoting Jun Zhao (2020-04-20 10:17:06)
> > > From: Jun Zhao <barryjzhao@tencent.com>
> > >
> > > Follow the http://id3.org/ID3v1, setting the year metadata
> > > for ID3v1.
> > >
> > > fix #8623
> > >
> > > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > > ---
> > >  libavformat/mp3enc.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
> > > index 34b753f..157174f 100644
> > > --- a/libavformat/mp3enc.c
> > > +++ b/libavformat/mp3enc.c
> > > @@ -45,6 +45,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key,
> > >      return !!tag;
> > >  }
> > >
> > > +// refer to: http://id3.org/ID3v1
> > >  static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
> > >  {
> > >      AVDictionaryEntry *tag;
> > > @@ -58,7 +59,7 @@ 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, "TPE1",    buf + 33, 30 + 1);       //author|artist
> > >      count += id3v1_set_string(s, "TALB",    buf + 63, 30 + 1);       //album
> > > -    count += id3v1_set_string(s, "TDRC",    buf + 93,  4 + 1);       //date
> > > +    count += id3v1_set_string(s, "TYER",    buf + 93,  4 + 1);       //year
> >
> > This will break for ID3v2.4, no?
> >
> Why? This change is just changing the ID3v1

The "date" tag is converted to "TDRC" for v2.4 and "TYER"/"TDAT" for
v2.3.
diff mbox series

Patch

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 34b753f..157174f 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -45,6 +45,7 @@  static int id3v1_set_string(AVFormatContext *s, const char *key,
     return !!tag;
 }
 
+// refer to: http://id3.org/ID3v1
 static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
 {
     AVDictionaryEntry *tag;
@@ -58,7 +59,7 @@  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, "TPE1",    buf + 33, 30 + 1);       //author|artist
     count += id3v1_set_string(s, "TALB",    buf + 63, 30 + 1);       //album
-    count += id3v1_set_string(s, "TDRC",    buf + 93,  4 + 1);       //date
+    count += id3v1_set_string(s, "TYER",    buf + 93,  4 + 1);       //year
     count += id3v1_set_string(s, "comment", buf + 97, 30 + 1);
     if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
         buf[125] = 0;