Python - eyeD3 Lame tag CRC check failed
Asked Answered
R

8

8

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?

Retro answered 15/4, 2016 at 0:0 Comment(8)
Did you ever figure this out?Colyer
@Colyer No unfortunately I did not.Retro
I eventually found a solution to this. I'll post it, as soon as I can find my script.Colyer
@Colyer did you found the solution ?Scuta
Did you find a solution? I'm trying to "catch" the warning as an error but it seems I can't (don't know how to) do it. I run my script on multiple files, so I'd love to know which one is the one causing the problem.Mylor
I never did sorry.Retro
If you are willing to brute force disable this message, look in site-packages/eyed3/mp3/headers.py line 578 or therabouts ...Due
@Mylor I was having the same issue trying to locate the offending files. To solve it, before the load I added a print statement like "Processing file" with the song name, and then a call to flush stdout. Then when you run your script you should see the warning show up directly after the song. Note that if you're outputting to a file, make sure to redirect stderr to stdout.Embus
A
3

found this did the trick for me

eyed3.log.setLevel("ERROR")

Python Eyed3 Warning

Apostle answered 14/3, 2022 at 12:21 Comment(0)
L
2

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.
Lowrance answered 10/4, 2020 at 17:28 Comment(1)
Super helpful. I wanted to mention that I found I had to add log_stream.seek(0) after the truncate to keep using the stream for multiple files. Also found it helpful to use llog.strip() to get rid of trailing newlines.Xanthippe
E
2

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.

Embus answered 2/10, 2020 at 1:5 Comment(0)
M
0

I ran into the same issue, my mp3 file was generated by ffmpeg and had this problem. Also, it didn't have any info set.

I manually (in Windows, using file properties) edited just the title and set it to "X", after which I was able to use the eyed3 without running into the CRC error.

Mariomariology answered 18/10, 2016 at 3:55 Comment(1)
I tried this but it didn't work for me. I tried also to reset the tag (audiofile.initTag() and then audiofile.tag.save() ) but it doesn't work either.Lowrance
G
0

I also get this error on some files, but it's not an actual Python error, it just gets printed to stdout. You can ignore the warning and rename the files in any way you see fit.

Gerdagerdeen answered 25/1, 2020 at 18:3 Comment(2)
Apologize, but I don't understand how renaming the mp3 file could fix this error ? (I tried of course, but it didn't work for me)Lowrance
@herve-guerin: Renaming the file does not fix the problem. The original issue had to do with renaming files. This error can be ignored while renaming files.Gerdagerdeen
D
0

I was able to suppress this error by doing this:

from logging import getLogger


  # (in main)
  # Suppress WARNINGS generated by eyed3
  getLogger().setLevel('ERROR')
Depone answered 25/1, 2021 at 1:14 Comment(0)
S
-1

You are accessing/modify files too fast. Faster than it actually loads or close properly. I add a small time sleep during each interval and solves the problem.

import string
import os
import eyed3
import time

count = 0

for root, dirs, filenames in os.walk('path'):
    for song in filenames:
        audiofile = eyed3.load(song)
        time.sleep(0.01)
Servility answered 11/5, 2020 at 15:4 Comment(4)
Why would a CRC be affected by how quickly you open the files? You can easily recreate this by opening just one offending file and seeing the warning still pop up.Embus
I don't think this makes too much sense. What does "too fast" mean? How do you know that sleeping ten milliseconds between files is enough -- should it be a longer sleep on faster machines?Wavemeter
I have a single file that is giving me this error. It has nothing to do with the speed at which you are opening files.Joshua
I have a script which scans a whole directory looking for missing cover-images. I get a bunch of these warnings. I tried adding time.sleep(0.1) after each eyed3.load(), and I still get warnings, but at a much lower rate per second.Brackett
E
-1

In my case, the error seemed to be a side effect of 'unwise settings' as suggested above. I had 'recorded' the mp3s from a vinyl record using Audacity and noticed high volume levels on the data. I redid the recording with lower gain. The problem went away!

Eyelet answered 26/3, 2021 at 17:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.