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

mp3 loading fails #945

Closed
nomota opened this issue Aug 12, 2019 · 6 comments
Closed

mp3 loading fails #945

nomota opened this issue Aug 12, 2019 · 6 comments
Assignees
Labels
question Issues asking for help doing something

Comments

@nomota
Copy link

nomota commented Aug 12, 2019

y, sr = librosa.load("my.mp3")

Traceback (most recent call last):
File "/home/esperanto/anaconda3/lib/python3.6/site-packages/librosa/core/audio.py", line 127, in load
with sf.SoundFile(path) as sf_desc:
File "/home/esperanto/anaconda3/lib/python3.6/site-packages/soundfile.py", line 627, in init
self._file = self._open(file, mode_int, closefd)
File "/home/esperanto/anaconda3/lib/python3.6/site-packages/soundfile.py", line 1182, in _open
"Error opening {0!r}: ".format(self.name))
File "/home/esperanto/anaconda3/lib/python3.6/site-packages/soundfile.py", line 1355, in _error_check
raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'my.mp3': File contains data in an unknown format.

Description

Steps/Code to Reproduce

Expected Results

Actual Results

Versions

Linux-4.4.0-17763-Microsoft-x86_64-with-debian-jessie-sid
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0]
NumPy 1.16.4
SciPy 1.1.0
librosa 0.7.0

@lostanlen
Copy link
Contributor

Hello @nomota, please read this: https://github.com/librosa/librosa#audioread-and-mp3-support

To fuel audioread with more audio-decoding power (e.g., for reading MP3 files),
you may need to install either ffmpeg or GStreamer.

Note that on some platforms, audioread needs at least one of the programs to work properly.

If you are using Anaconda, install ffmpeg by calling

conda install -c conda-forge ffmpeg

If you are not using Anaconda, here are some common commands for different operating systems:

  • Linux (apt-get): apt-get install ffmpeg or apt-get install gstreamer1.0-plugins-base gstreamer1.0-plugins-ugly
  • Linux (yum): yum install ffmpeg or yum install gstreamer1.0-plugins-base gstreamer1.0-plugins-ugly
  • Mac: brew install ffmpeg or brew install gstreamer
  • Windows: download binaries from this website

For GStreamer, you also need to install the Python bindings with

pip install pygobject

@lostanlen lostanlen added the question Issues asking for help doing something label Aug 12, 2019
@lostanlen lostanlen self-assigned this Aug 12, 2019
@paraclete-pizza
Copy link

The support text lostanlen shared unfortunately doesn't seem to work for Windows machines (or is missing key steps). Installation of the GStreamer binaries does not solve the issue, and the pip command to install pygobject elicits an error. At present, at least on Windows, it looks like Librosa can't parse MP3s.

@bmcfee
Copy link
Member

bmcfee commented Jul 29, 2020

At present, at least on Windows, it looks like Librosa can't parse MP3s.

It definitely can, we include this in our windows platform continuous integration tests.

If it's not working on your installation, there is a problem with the upstream decoding libraries (audioread -> ffmpeg). Be sure to follow the installation instructions carefully.

@paraclete-pizza
Copy link

That gives me some hope! Though I've been hitting my head against this problem for days, now,

Are there installation instructions anywhere that I could "follow carefully" to install ffmpeg? The instructions above from the Librosa git only cover GStreamer, and, as noted, the required pip installation of pygobject generates an error (an enormous, multi-screen error, headed with "ERROR: Command errored out with exit status 1:" that Google has not helped with).

If ffmpeg is a viable alternative to GStreamer for Windows, I haven't found installation instructions that have successfully helped it interface with Python. Just the usual instructions to download ffmpeg to a directory and add it to Windows Path. But when followed carefully, they still don't seem to affect my Librosa scripts' ability to parse MP3s.

On your Windows tests, are you using ffmpeg rather than GStreamer? I feel like I've gotten better at untangling the various dependency knots across different Python versions, and managing installation of packages, but this has had me stymied for a while now (and I'm working with large enough file sets that I can't just convert them all to ogg to make them work)!

@bmcfee
Copy link
Member

bmcfee commented Jul 30, 2020

On your Windows tests, are you using ffmpeg rather than GStreamer?

Yes, the relevant parts of our Appveyor setup are the following:

librosa/appveyor.yml

Lines 16 to 24 in 4b827ce

install:
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- "IF NOT EXIST %MINICONDA%\\envs\\test-environment-%PYTHON_VERSION% conda create -q -n test-environment-%PYTHON_VERSION% python=%PYTHON_VERSION% numpy scipy coverage scikit-learn!=0.19.0 numba"
- "activate test-environment-%PYTHON_VERSION%"
- conda info -a
- conda install -c conda-forge ffmpeg
- pip install -e .[tests]

Lines 17-22 create the conda environment, line 23 installs ffmpeg via conda-forge, and line 24 installs the remaining dependencies needed for testing.

Note that this is all from the main development branch. If you're using the packaged version, the following ought to suffice:

conda install -c conda-forge ffmpeg librosa

@its-just-jo
Copy link

its-just-jo commented Jan 17, 2021

I'm getting this error even with ffmpeg installed via anaconda.

Are there any other solutions?

RuntimeError: Error opening '/path/000002.mp3': Format not recognised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues asking for help doing something
Development

No branches or pull requests

5 participants