dhowden / tag

ID3, MP4 and OGG/FLAC metadata parsing in Go
BSD 2-Clause "Simplified" License
558 stars 72 forks source link

Support MP4 tags that are not mean `com.apple.iTunes` #100

Closed nzoschke closed 7 months ago

nzoschke commented 9 months ago

I have MP4 files with tags written by Serato and Mixed In Key, popular DJ software.

These tags have mean com.mixedinkey.mixedinkey or com.serato.dj instead of com.apple.iTunes, so tag does not find them.

In the code I see that this library returns no tag data if it encounters a mean != com.apple.iTunes. Can we relax that?

https://github.com/dhowden/tag/blob/master/mp4.go#L271

diff --git a/mp4.go b/mp4.go
index 6523397..b7d959e 100644
--- a/mp4.go
+++ b/mp4.go
@@ -268,9 +268,10 @@ func readCustomAtom(r io.ReadSeeker, size uint32) (_ string, data []string, _ er
                return "", nil, err
        }

-       if subNames["mean"] != "com.apple.iTunes" || subNames["name"] == "" || len(data) == 0 {
+       if subNames["name"] == "" || len(data) == 0 {
                return "----", nil, nil
        }
+
        return subNames["name"], data, nil
 }

Before:

% tag -raw track.mp4
Metadata Format: MP4
File Type: 
 Title: 
 Album: 
 Artist: 
 Composer: 
 Genre: 
 Year: 0
 Track: 0 of 0
 Disc: 0 of 0
 Picture: <nil>
 Lyrics: 
 Comment: 

"energylevel": "\x00\x00\x00\x007"
"initialkey": "\x00\x00\x00\x0010A"

After:

% tag -raw track.mp4
Metadata Format: MP4
File Type: 
 Title: No Brain
 Album: 
 Artist: Etienne de Crécy
 Composer: 
 Genre: 
 Year: 2011
 Track: 0 of 0
 Disc: 0 of 0
 Picture: <nil>
 Lyrics: 
 Comment: 10A - Energy 7

"\xa9too": "Lavf60.3.100"
"\xa9cmt": "10A - Energy 7"
"\xa9day": "20110330"
"\xa9ART": "Etienne de Crécy"
"\xa9nam": "No Brain"
"beatgrid": "<BASE64_DATA>"
"markersv2": "<BASE64_DATA>"
"cuepoints": "<BASE64_DATA>"
"energy": "<BASE64_DATA>"
"tmpo": 0
"energylevel": "\x00\x00\x00\x007"
"initialkey": "\x00\x00\x00\x0010A"
"key": "<BASE64_DATA>"
"markers": "<BASE64_DATA>"