essentia icon indicating copy to clipboard operation
essentia copied to clipboard

Python crashes when trying to load an audio with an invalid codec

Open xavierfav opened this issue 5 years ago • 6 comments

I sometimes get some errors that make python to crash when trying to load an audio with the MonoLoader. Even when using a try/except clause, my program crashes sometimes. I got different kind of errors:

  • 29095 segmentation fault (core dumped) ipython

  • free(): invalid pointer 28724 abort (core dumped) ipython

The audio file is the original file of https://freesound.org/people/arundasstp/sounds/402803/

Here is one of the traceback:

In [3]: x = MonoLoader(filename='402803.wav')()                           
--------------------------------------------------------------------------
RuntimeError                             Traceback (most recent call last)
<ipython-input-3-3f805c69d99c> in <module>
----> 1 x = MonoLoader(filename='402803.wav')()

~/Documents/dev/fun/percussive-decoder/venv/lib/python3.6/site-packages/essentia/standard.py in __init__(self, **kwargs)
     42 
     43             # configure the algorithm
---> 44             self.configure(**kwargs)
     45 
     46         def configure(self, **kwargs):

~/Documents/dev/fun/percussive-decoder/venv/lib/python3.6/site-packages/essentia/standard.py in configure(self, **kwargs)
     62                 kwargs[name] = convertedVal
     63 
---> 64             self.__configure__(**kwargs)
     65 
     66         def compute(self, *args):

RuntimeError: Error while configuring MonoLoader: AudioLoader: Unsupported codec!

In [4]: x                                                                 
--------------------------------------------------------------------------
NameError                                Traceback (most recent call last)
<ipython-input-4-6fcf9dfbd479> in <module>
----> 1 x

NameError: name 'x' is not defined

In [5]: free(): invalid size                                              
[1]    30008 abort (core dumped)  ipython

xavierfav avatar Mar 26 '19 13:03 xavierfav

I was dealing with this issue (AudioLoader: Unsupported codec!) in the past couple of days, too. The error message was really confusing because *.wav is obviously a supported codec.

I tried to create a static build of Essentia and its third-party dependencies when this error surfaced.

The problem was an outdated ffmpeg version that was built with Essentia's third-party build-script:

https://github.com/MTG/essentia/blob/master/packaging/debian_3rdparty/build_ffmpeg.sh

I never had any issues with my system-installation of Essentia which also uses my system-installation of ffmpeg-4.1. This happened only with the static build of Essentia which used ffmpeg-2.8.12.

Now, I don't know if you have the same problem but checking your ffmpeg version and possibly updating it if too old, might help to resolve this.

dschwertfeger avatar Mar 27 '19 15:03 dschwertfeger

Faced the same problem with ADPCM encoded files present in UrbanSound8k:

Input File     : '/home/palonso/data/raw/urbansound8k/audio/fold8/36429-2-0-7.wav'
Channels       : 1
Sample Rate    : 11024
Precision      : 14-bit
Duration       : 00:00:04.04 = 44500 samples ~ 302.749 CDDA sectors
File Size      : 22.9k
Bit Rate       : 45.3k
Sample Encoding: 4-bit MS ADPCM

In my case Essentia was installed from the last dev wheels (essentia_tensorflow-2.1b6.dev311) which means it relies on our custom build of ffmpeg-2.8.12.

It seems like since version 3.0 they support new ADPCM decoders that may help on this issue.

@dbogdanov should we consider upgrading FFMPEG?

palonso avatar Sep 16 '20 07:09 palonso

Yes, this is in the wishlist. We can use ffmpeg-3.4.8 which is in Ubuntu 18.04 LTS.

We should be careful though as our build scripts for ffmpeg can break due flag changes, etc.

dbogdanov avatar Sep 17 '20 13:09 dbogdanov

I have the same issue as @xavierfav and it doesn't seem related to the version of ffmpeg. I built with the versions available in both Ubuntu 18.04 LTS and Ubuntu 20.04 LTS and it still crashes. It happens when I try to load a corrupted wav file.

charlie-rbchd avatar Nov 06 '20 15:11 charlie-rbchd

@palonso were you able to resolve it later? i'm using the urbansound8k as well and facing this same issue but on colab.

@joelrobichaud Did excluding the corrupted wav file by skipping it work? is it possible to identify such a file other than including generic error handling(try except)?

dilipupf avatar Feb 11 '23 10:02 dilipupf

Cannot reproduce this error in my local build from source, the file loads fine. Therefore, this error is related to the FFMpeg dependencies in Python wheels. We'll update the way the dependencies are managed in the wheels soon.

dbogdanov avatar Feb 13 '23 13:02 dbogdanov