Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Xing stream size off by more than 1%, fuzzy seeking may be even more fuzzy than by design! #708

Open
louisfh opened this issue May 4, 2023 · 8 comments
Assignees
Labels

Comments

@louisfh
Copy link
Member

louisfh commented May 4, 2023

These warnings/errors are being raised on reading some mp3 files.

[src/libmpg123/layer3.c:INT123_do_layer3():1801] error: dequantization failed!
[src/libmpg123/layer3.c:INT123_do_layer3():1773] error: part2_3_length (3360) too large for available bit count (3240)
Warning: Xing stream size off by more than 1%, fuzzy seeking may be even more fuzzy than by **design!**

I tried converting some mp3 files that raise this warning to WAV by doing:

a = Audio.from_file("file1.mp3")
a.save("file2.WAV")

And they still raise the warning.

@louisfh
Copy link
Member Author

louisfh commented May 4, 2023

https://sourceforge.net/p/mpg123/bugs/275/ This discussion suggests it is an issue that libmpg123 encounters if the LAME/Xing header for an mp3 file does not match the file contents. e.g. if a Variable bitrate file has constant bit rate information in the Xing header.

@sammlapp sammlapp added the discuss Long term ideas to consider label Aug 16, 2023
@sammlapp
Copy link
Collaborator

Reproducible example with an audio file, and specific version numbers for librosa, libmpg123 (if used by librosa), or whatever underlying package is relevant

@louisfh
Copy link
Member Author

louisfh commented Sep 7, 2023

Mp3 file from here: https://xeno-canto.org/157067

Warning is being raised by librosa (or something under the hood that librosa uses, like audioread). Using librosa 0.10.1:

import librosa
broke_file = "/path/to/157067.mp3"
librosa.load(broke_file)

raises the warning. We could filter warnings at the point of loading audio.

@louisfh
Copy link
Member Author

louisfh commented Sep 7, 2023

It's not really an us problem, but it is an annoying thing for users to see flooding their stdout. Hiding warnings (or some subset of them? If that's possible) might be helpful for helping new users not to be overwhelmed.

@sammlapp sammlapp added this to the 0.11.0 milestone Apr 12, 2024
@sammlapp
Copy link
Collaborator

let's find a way to filter it out as specifically as possible

@louisfh
Copy link
Member Author

louisfh commented Jun 7, 2024

I have tried wrapping the librosa.load call in our Audio module with a warnings filter, e.g.:

        ## Load samples ##
        # ignore the Xing warnings from librosa here
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            samples, sr = librosa.load(
                path,
                sr=sample_rate,
                res_type=resample_type,
                mono=True,
                offset=offset,
                duration=duration,
                dtype=None,
            )

But I still can't silence the warning. @sammlapp I don't think I understand how Warnings are handled well enough to fix this issue.

@louisfh
Copy link
Member Author

louisfh commented Jun 7, 2024

I also tried wrapping the import statements with the warning filter, e.g.

with warnings.catch_warnings():
    # ignore  all warnings
    warnings.simplefilter("ignore")
    import librosa
    import librosa.core.audio
    import soundfile

@louisfh
Copy link
Member Author

louisfh commented Jun 10, 2024

OK it looks like the problem might be that libmpg123 is printing directly to stderr. It's a C library, not a python package, so I assume the Python warnings system is not going to catch these. You should be able to catch this with redirect_stderr, but apparently that doesn't work either. bastibe/python-soundfile#435

@sammlapp sammlapp added blocked and removed discuss Long term ideas to consider labels Sep 12, 2024
@sammlapp sammlapp removed this from the 0.11.0 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants