n10v / id3v2

🎵 ID3 decoding and encoding library for Go
https://pkg.go.dev/github.com/bogem/id3v2/v2
MIT License
337 stars 52 forks source link

AddUnsynchronisedLyricsFrame added as TXXX #30

Closed streambinder closed 7 years ago

streambinder commented 7 years ago

I would expect AddUnsynchronisedLyricsFrame() would result in a new USLT frame being inserted into id3 file data structure, but a TXXX frame get inserted, instead.

n10v commented 7 years ago

This can't happen. Please provide an example of code reproducing this issue.

streambinder commented 7 years ago

I actually compared two cases. The first one is about an mp3 produced by the alteration of metadata using your library, using this snippet (in the same section I alter several tags, such as APIC, TALB, TDRC, TIT2, TPE1, TRCK and a custom TXXX, everything working as expected, but for USLT one):

track_mp3.AddUnsynchronisedLyricsFrame(id3.UnsynchronisedLyricsFrame{
    Encoding:          id3.EncodingUTF8,
    Language:          "eng",
    ContentDescriptor: track.Title,
    Lyrics:            track.Lyrics,
})

(obviously track.Title and track.Lyrics are strings and id3 is the alias for id3v2). Executing mid3v2 -v /path/to.mp3, here's the output:

IDv2 tag info for /path/to.mp3
APIC=cover front, Front cover (image/png, 892496 bytes)
TALB=...
TDRC=2015
TIT2=...
TPE1=...
TRCK=13
TSSE=Lavf57.71.100
TXXX=lyrics-[...]

The second case is about a song whose metadata got altered using an Android application. The same command, executed on the latter is the following:

IDv2 tag info for /path/to/other.mp3
APIC=cover front, Front cover (image/png, 892496 bytes)
TALB=...
TDRC=2015
TIT2=...
TPE1=...
TRCK=13
TSSE=Lavf57.71.100
USLT=[unrepresentable data]
n10v commented 7 years ago

I can't reproduce it and I need more data to figure out, what happens. Please send these two mp3s.

streambinder commented 7 years ago

Here you have. OneDirection-History.zip

n10v commented 7 years ago

Consider this script I wrote:

package main

import (
    "fmt"

    "github.com/bogem/id3v2"
)

func main() {
    tag, err := id3v2.Open(filename, id3v2.Options{Parse: true})
    if err != nil {
        fmt.Println(err)
    }
    defer tag.Close()

    fmt.Println("Frames before:")
    for id := range tag.AllFrames() {
        fmt.Println(id)
    }

    tag.AddUnsynchronisedLyricsFrame(id3v2.UnsynchronisedLyricsFrame{
        Encoding:          id3v2.EncodingUTF8,
        Language:          "eng",
        ContentDescriptor: "Desc",
        Lyrics:            "Lyrics",
    })

    fmt.Println("\nFrames after:")
    for id := range tag.AllFrames() {
        fmt.Println(id)
    }
}

For filename = "OneDirection_History_Bogem.mp3" it prints:

Frames before:
TSSE
TIT2
TPE1
TALB
TRCK
TDRC
APIC
TXXX

Frames after:
TALB
TRCK
TDRC
APIC
TXXX
TSSE
TIT2
TPE1
USLT // <-

And if we save it, it prints:

Frames before:
TPE1
TALB
TRCK
APIC
TIT2
TDRC
TXXX
TSSE
USLT // <-

So USLT frame is saved correctly. I have no idea, what's wrong in your program. It's impossible for id3v2 to behave in the way it works on your machine. Maybe, try to update id3v2 library: go get -u github.com/bogem/id3v2

streambinder commented 7 years ago

You're right. It really was my fault, your library was doing anything as expected, too. If you're interested, anyway, applying ffmpeg conversion to increase max_volume and increasing bitrate to the max allowed seems to drop USLT frame in favor of the TXXX one.