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

LocalAudioFile function fails to load files #47

Open
jmwenda opened this issue Jul 1, 2015 · 2 comments · May be fixed by #52
Open

LocalAudioFile function fails to load files #47

jmwenda opened this issue Jul 1, 2015 · 2 comments · May be fixed by #52

Comments

@jmwenda
Copy link

jmwenda commented Jul 1, 2015

When I add or use the LocalAudioFile("") function, and pass the file path parameter to the function, the following error is produced. Regardless of the file or the path, the error is always reproduced. This is the case on both Linux and Mac computers. Regardless of .wav or .mp3 files, the same error keeps popping up.

audiofile = audio.LocalAudioFile('/tmp/tmp4e8cYC.wav')
['en-ffmpeg', '-i', '/tmp/tmp4e8cYC.wav', '-y', '-ac', '2', '-ar', '44100', '/tmp/tmphabAB8.wav']
Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/musicvenv/local/lib/python2.7/site-packages/echonest/remix/audio.py", line 944, in init
sampleRate=sampleRate, numChannels=numChannels)
File "/home/ubuntu/musicvenv/local/lib/python2.7/site-packages/echonest/remix/audio.py", line 403, in init
self.load()
File "/home/ubuntu/musicvenv/local/lib/python2.7/site-packages/echonest/remix/audio.py", line 421, in load
numChannels=self.numChannels, sampleRate=self.sampleRate, verbose=self.verbose)
File "/home/ubuntu/musicvenv/local/lib/python2.7/site-packages/echonest/remix/support/ffmpeg.py", line 88, in ffmpeg
close_fds=(not win)
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

@SuzanaK
Copy link

SuzanaK commented Feb 28, 2016

I have the same problem.

@mikeperri
Copy link

Make sure you have ffmpeg installed and en-ffmpeg points to your ffmpeg installation.

I think this is the error you're supposed to see:
en-ffmpeg not found! Please make sure ffmpeg is installed and create a link as follows: sudo ln -s which ffmpeg /usr/local/bin/en-ffmpeg Alternatively, import echonest.remix.support.ffmpeg and modify ffmpeg.FFMPEG to name the appropriate binary.

That OSError is thrown when the subprocess module tries to execute a command without a shell, but the command isn't found. You can test it like this:

>>> subprocess.call("not-a-real-command", shell=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

>>> subprocess.call("not-a-real-command", shell=True)
/bin/sh: not-a-real-command: command not found
127

The stack trace shows an error at line 88 of echonest/remix/support/ffmpeg.py, after it called subprocess.Popen with shell=False to execute the ffmpeg command. So that explains why we just got the OSError and not the more helpful message. If you change shell to True in your local ffmpeg.py you should see the real error.

The ffmpeg.py file has logic to handle different error messages thrown by the ffmpeg process, which is strange since it doesn't seem it would ever make it there. If you look at the blame on Github, the change from shell=True to shell=False was made in September 2014, a couple of years after the logic to handle the different ffmpeg errors was added. So this has probably been happening since the change to shell=
False was made.

It sounds like using shell=False is the way to go. So we could leave that but show the intended error message by doing something like this in ffmpeg.py:

    try:
        p = subprocess.Popen(
                command,
                shell=False,
                stdin=(None if filename else subprocess.PIPE),
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                close_fds=(not win)
        )
    except OSError:
        ffmpeg_error_check("command not found")

mikeperri added a commit to mikeperri/remix that referenced this issue Apr 25, 2016
mikeperri added a commit to mikeperri/remix that referenced this issue Apr 25, 2016
mikeperri added a commit to mikeperri/remix that referenced this issue Apr 25, 2016
mikeperri added a commit to mikeperri/remix that referenced this issue Apr 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants