Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - eyeD3 Lame tag CRC check failed

I am trying to write a script to clean up mp3 file names using Python and eyeD3 but I am getting "WARNING:eyed3.mp3.headers:Lame tag CRC check failed" when I try to load an mp3 file using the following script

import string
import os
import eyed3

count = 0

for root, dirs, filenames in os.walk('path'):
    for song in filenames:
        audiofile = eyed3.load(song)

Because of this I am not able to rename most of the files in my library. Any experience on this subject or a different library to use?

like image 618
Jay Bell Avatar asked Apr 15 '16 00:04

Jay Bell


2 Answers

I found a first turnaround to detect those eye3d "errors" sadly sent to stdout : In fact, eyed3 is not as fully dirty as it seems because its errors and in fact log.warnings, so I got those errors by looking at the log in this way : - before eye3d call, I redirect the log to a stringIO - after the eye3d call, I check if this stringIO is still empty (or not)

sample code :

import logging
import io
import eyed3

log_stream = io.StringIO()
logging.basicConfig(stream=log_stream, level=logging.INFO)
audiofile = eyed3.load('myfullfilename')
llog = log_stream.getvalue()
if llog:
    # deal here with the error message which in llog
    # and then purge the log_stream to reuse it for next eye3d call
    log_stream.truncate(0)
# all this code can be improved : enclose it in a try..catch, etc.
like image 146
herve-guerin Avatar answered Nov 06 '22 20:11

herve-guerin


Saw a couple SO questions without clear answers; this one seems to have the most action. I was experiencing this issue too, but it's clear the error has nothing to do with anyone's particular Python scripting. You can tell by running the command line eyeD3 tool as follow (output abbreviated):

% eyeD3 -v '03 - The Presidents Of The United States Of America - Lump.mp3'
eyed3.mp3.headers:WARNING: Lame tag CRC check failed
.../03 - The Presidents Of The United States Of America - Lump.mp3 [ 5.28 MB ]

ID3 v2.4:
title: Lump
artist: The Presidents Of The United States Of America

You can see more info about the LAME tag this way:

% eyeD3 -P lameinfo '03 - The Presidents Of The United States Of America - Lump.mp3'
eyed3.mp3.headers:WARNING: Lame tag CRC check failed

Encoder Version     : LAME3.82U
LAME Tag Revision   : 10

Music CRC-16        : 5555
LAME Tag CRC-16     : 5555

I haven't really looked into it, but my guess on how it works is that the CRC calculated doesn't match the one in the tag?

Unfortunately I'm not sure how to actually fix the LAME tag with eyeD3 or any other tool. However, what I was able to do fix the warning was re-encode and overwrite the file (on Mac I used the program "Switch Sound File Converter"). The LAME tag seems to be lost in the process (which would make sense since LAME is related to encoding):

% eyeD3 -P lameinfo '03 - The Presidents Of The United States Of America - Lump.mp3'

03 - The Presidents Of The United States Of America - Lump.mp3  [ 5.71 MB ]
-------------------------------------------------------------------------------
No LAME Tag

and

% eyeD3  '03 - The Presidents Of The United States Of America - Lump.mp3'
.../03 - The Presidents Of The United States Of America - Lump.mp3 [ 5.71 MB ]

ID3 v2.3:
title: Lump

And thus the warning goes away (note the change in ID3 tag versions to an older version too...I then used a program called Tagr to update the tags and it wrote back the newest version). I'm currently not sure how else to do it, but I'd love to know if anyone else has ideas on different tools to use or a deeper understanding on how this all works.

like image 25
Billy Avatar answered Nov 06 '22 18:11

Billy