question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoBackendError despite a backend (specifically FFmpeg) being installed

See original GitHub issue

Hello!

This is my first time posting an issue, so please cut me some slack if I’m not following some protocol!

I was trying to use python’s librosa package on Windows 10 and encountered the following issue.

After running x, _ = librosa.load('data/fma_small/000/000002.mp3', sr = None) I receive this stack trace:

---------------------------------------------------------------------------
NoBackendError                            Traceback (most recent call last)
<ipython-input-2-15a8daa0e7fd> in <module>()
      1 start, end = 7, 17
      2 filename = utils.get_audio_path(AUDIO_DIR, 2)
----> 3 x, sr = librosa.load(filename, sr = None, mono = True)

Q:\Program Files\Anaconda3\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
    105 
    106     y = []
--> 107     with audioread.audio_open(os.path.realpath(path)) as input_file:
    108         sr_native = input_file.samplerate
    109         n_channels = input_file.channels

Q:\Program Files\Anaconda3\lib\site-packages\audioread\__init__.py in audio_open(path)
    112 
    113     # All backends failed!
--> 114     raise NoBackendError()

NoBackendError:

Out of curiosity, I also tried to run audioread.ffdec.FFmpegAudioFile('data/fma_small/000/000002.mp3') (since I know that FFmpeg is installed) but I received:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Q:\Program Files\Anaconda3\lib\site-packages\audioread\ffdec.py in __init__(self, filename, block_size)
    126                 stderr=subprocess.PIPE,
--> 127                 stdin=self.devnull,
    128             )

Q:\Program Files\Anaconda3\lib\site-packages\audioread\ffdec.py in popen_multiple(commands, command_args, *args, **kwargs)
     88         try:
---> 89             return subprocess.Popen(cmd, *args, **kwargs)
     90         except OSError:

Q:\Program Files\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
    946                                 errread, errwrite,
--> 947                                 restore_signals, start_new_session)
    948         except:

Q:\Program Files\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1223                                          cwd,
-> 1224                                          startupinfo)
   1225             finally:

FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

NotInstalledError                         Traceback (most recent call last)
<ipython-input-6-be3b460211e8> in <module>()
----> 1 audioread.ffdec.FFmpegAudioFile(filename)

Q:\Program Files\Anaconda3\lib\site-packages\audioread\ffdec.py in __init__(self, filename, block_size)
    129 
    130         except OSError:
--> 131             raise NotInstalledError()
    132 
    133         finally:

NotInstalledError:

Again, I have FFmpeg installed, and ffmpeg works as a command in cmd.

Is anyone able to spot the problem?

Thanks!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:39 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
carlthomecommented, Jul 29, 2018

Not really, no. I eventually started calling ffmpeg via subprocess.Popen and am pretty happy with more explicit control for my purposes.

import shlex
import subprocess

import numpy as np


def decoder(path, duration=3.0, channels=2, sample_rate=44100, dtype=np.float32):
    formats = {np.int16: 's16le', np.float32: 'f32le'}
    args = f'''
    ffmpeg 
    -v error
    -n
    -i "{path}" 
    -f {formats[dtype]} 
    -ac {channels} 
    -ar {sample_rate} 
    -
    '''
    args = shlex.split(args)

    buffer_size = int(channels * np.dtype(dtype).itemsize * duration * sample_rate)

    with subprocess.Popen(args, stdout=subprocess.PIPE) as pipe:
        while True:
            buffer = pipe.stdout.read(buffer_size)
            audio = np.frombuffer(buffer, dtype=dtype)
            audio = np.reshape(audio, (-1, channels))
            yield audio
            if len(buffer) < buffer_size:
                break


for x in decoder('piano.wav'):
    print(x.shape)
from IPython.display import Audio

audio = np.concatenate(list(decoder('piano.wav')))
Audio(audio.T, rate=44100)

If you’re having trouble with audioread you could of course try libsoundfile and see if that works:

import soundfile as sf

y, sr = sf.read('audio.ogg')
2reactions
raffaelbdcommented, Dec 3, 2019

YES, “fixed” it.

Following this intuition of the PATH environment variable behaving differently from the rest of my system I just copied ffmpeg to the parent folder of the directory and it worked! And then I realized I hardly ever close PyCharm, so I restarted it and it works! This issue also happens with terminals (environment variables don’t take effect unless you open a new one). I m having same problems , despite installing ffmpeg. please give me a solution.

my code was: D = [] # Dataset for row in valid_data.itertuples(): y, sr = librosa.load(‘F:\paper\Bangla ASR\segmented/augmented 1/’ + (row.path))
ps = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=52) if ps.shape != (52, 130): continue D.append( (ps, row.classID) )


NoBackendError Traceback (most recent call last) <ipython-input-6-91f60cabb456> in <module> 1 D = [] # Dataset 2 for row in valid_data.itertuples(): ----> 3 y, sr = librosa.load(‘F:\paper\Bangla ASR\segmented/augmented 1/’ + (row.path)) 4 ps = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=52) 5 if ps.shape != (52, 130): continue

~.conda\envs\RaffaelEnv\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type) 117 118 y = [] –> 119 with audioread.audio_open(os.path.realpath(path)) as input_file: 120 sr_native = input_file.samplerate 121 n_channels = input_file.channels

~.conda\envs\RaffaelEnv\lib\site-packages\audioread_init_.py in audio_open(path) 114 115 # All backends failed! –> 116 raise NoBackendError()

NoBackendError:

N.B: I restarted jupyter notebook so many times but still problem exists

Read more comments on GitHub >

github_iconTop Results From Across the Web

No Backend error despite of downloading ffmpeg and setting ...
I am getting this error with .mp3 extension, with wav it is working properly . import librosa as lib t,s_r=lib.load(r ...
Read more >
NoBackendError despite a backend (specifically FFmpeg) being ...
Hello! This is my first time posting an issue, so please cut me some slack if I'm not following some protocol! I was...
Read more >
audioread.exceptions.NoBackendError in librosa - CodeAntenna
Problem: NoBackendError; Solution; This is the real solution to NoBackendError despite a backend (specifically FFmpeg) being installed. Method 1; Method 2.
Read more >
librosa打开文件是显示NoBackendError - CSDN博客
在conda环境里面,conda install ffmpeg -c conda -forge 即可。 ... solution to NoBackendError despite a backend (specifically FFmpeg) being ...
Read more >
Python librosa NoBackendError even though ffmpeg is installed
You have this line of code: audio = issues librosa.load(pathToJson). It seems to me that you are accidentally trying trying to load JSON ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found