Kodi Community Forum

Full Version: Kodi not detecting tags in some FLAC files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a weird problem with an album that is in FLAC format and Kodi doesn't find its tags, despite it being tagged properly with Picard. The debug logs show the following after re-tagging and scanning:

Code:
2022-09-16 16:44:31.706 T:21331   DEBUG <general>: DoScan Rescanning dir 'smb://192.168.42.152:445/seagate/music/Jan Koch - Ewiger Mai/' due to change
2022-09-16 16:44:31.763 T:21331   DEBUG <general>: CSMBFile::Open - opened smb://USERNAME:[email protected]:445/seagate/music/Jan Koch - Ewiger Mai/01 Ewiger Mai.flac, fd=10000
2022-09-16 16:44:31.849 T:21331   DEBUG <general>: CSMBFile::Close closing fd 10000
2022-09-16 16:44:31.875 T:21331   DEBUG <general>: ScanTags - No tag found for: smb://192.168.42.152:445/seagate/music/Jan Koch - Ewiger Mai/01 Ewiger Mai.flac

However, the file is properly tagged. Using `metaflac --list` you can see the metadata present in the file, see https://termbin.com/6t23 for the output. 

I used Picard to remove existing tags before re-tagging and to remove id3 from FLAC files as well, as recommended in https://kodi.wiki/view/Music_tagging#Cle...sting_Tags . However, the results are the same.

At this point I am completely out of ideas. I have other FLAC albums that work just fine, and checking their metadata I don't see anything different, so I am pretty lost.
Forgot to mention, this is Kodi 19.4 on OSMC in a Raspberry Pi, in case it is relevant.
If you can upload one of the files from the album, I can see if I can reproduce it on my side. I am pretty familiar with the tag loading code and may be able to do some debugging.
I wouldn't want to upload a copyrighted track somewhere, but maybe I can use head to cut and upload only the metadata portion? Not sure if that would work though with a flac file.
I ran one of the files through ffmpeg with copy and map_metadata to extract only the first second of audio while preserving the metadata. Interestingly, ffmpeg modified a bit the order of the metadata in the file, and now that file gets scanned in the library without issues.

This is how I did the copy:

Code:

ffmpeg -ss 0 -i 01\ Ewiger\ Mai.flac -map_metadata 0 -t 1 -c copy output.flac

Here is the metaflac's output on the resulting file https://termbin.com/dcf1

I suppose I could just pass the entire album through ffmpeg and that would solve the issue, but I do think that it's likely that there's a bug in Kodi that it would be worth investigating.
Notice that the length field in the Vorbis Comment metadata block header changed from 935 to 941. ffmpeg did add the encoder comment in the second file, but this accounts for much more than 6 bytes. It's likely that the length field in your original file is incorrect.

Kodi uses the TagLib library to read the tags. I did a brief check of the source code. It appears that TagLib will indeed reject any FLAC metadata block with an actual length that doesn't match the length field in the header. If you want to verify this, you can run Kodi with a debug build of TagLib and check the console output. That error message in the linked code should be outputted to stderr.

I think the best way to proceed is to remux the album using ffmpeg as you mentioned in your previous post. I don't think this can be considered a bug in TagLib/Kodi since your files are corrupt (assuming the above diagnosis is true).
Thanks for the insight; this helps a lot!

Unfortunately I don't think your theory holds. I built taglib with debugging enabled and ran the tag reader example on one of the track files and it's able to read the tags properly (https://termbin.com/hpk8); no debug output either. Probably irrelevant, but I built this locally on my computer as it's faster that way; I doubt this is a rpi/arm specific bug, but who knows!