10se1ucgo / pyjam

An open source, cross-platform audio player for Source and GoldSrc engine based games, written in Python
http://10se1ucgo.github.io/pyjam
GNU Lesser General Public License v3.0
31 stars 4 forks source link

Audio converter not working on OSX #2

Closed gabsens closed 8 years ago

gabsens commented 8 years ago

After selecting the input and output folders for the audio converter and clicking on "OK",, I get the following error

An error has occured

Traceback (most recent call last): File "/Users/gabsens/Downloads/pyjam-1.2.3/jam_tools.py", line 85, in _wrap_exceptions return func(_args, _kwargs) File "/Users/gabsens/Downloads/pyjam-1.2.3/ffmpeg.py", line 180, in run convert = convert_audio(track, file, self.rate, self.vol) File "/Users/gabsens/Downloads/pyjam-1.2.3/ffmpeg.py", line 332, in convert_audio return subprocess.call(cmd) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 537, in call with Popen(_popenargs, _kwargs) as p: File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 859, in init restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1457, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/ffmpeg -y -i "/Users/gabsens/Downloads/pyjam-1.2.3/downloads/Oczosinko.m4a" -map_metadata -1 -ac 1 -aq 100 -acodec pcm_s16le -ar 22050 -af volume=0.85 "/Users/gabsens/Downloads/pyjam-1.2.3/downloads/Oczosinko.wav"'

The problem is not ffmpeg, nor the command you're sending to ffmpeg, because when I type

'/usr/local/bin/ffmpeg -y -i "/Users/gabsens/Downloads/pyjam-1.2.3/downloads/Oczosinko.m4a" -map_metadata -1 -ac 1 -aq 100 -acodec pcm_s16le -ar 22050 -af volume=0.85 "/Users/gabsens/Downloads/pyjam-1.2.3/downloads/Oczosinko.wav"

in the Terminal, the conversion is done without any problem.

INFORMATION:

LOG:

21:03:40 INFO: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
21:03:40 INFO: uname_result(system='Darwin', node='MacBook-Pro-de-gabriel.local', release='14.5.0', version='Darwin Kernel Version 14.5.0: Tue Sep  1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64', machine='x86_64', processor='i386')
21:03:40 INFO: Generating track list with path .
21:04:11 CRITICAL: Traceback (most recent call last):
  File "/Users/gabsens/Downloads/pyjam-1.2.3/jam_tools.py", line 85, in _wrap_exceptions
    return func(*args, **kwargs)
  File "/Users/gabsens/Downloads/pyjam-1.2.3/ffmpeg.py", line 180, in run
    convert = convert_audio(track, file, self.rate, self.vol)
  File "/Users/gabsens/Downloads/pyjam-1.2.3/ffmpeg.py", line 332, in convert_audio
    return subprocess.call(cmd)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 537, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/ffmpeg -y -i "/Users/gabsens/Downloads/pyjam-1.2.3/downloads/Oczosinko.m4a" -map_metadata -1 -ac 1 -aq 100 -acodec pcm_s16le -ar 22050 -af volume=0.85 "/Users/gabsens/Downloads/pyjam-1.2.3/downloads/Oczosinko.wav"'
10se1ucgo commented 8 years ago

It seems that for whatever reason, subprocess isn't able to run FFmpeg. I'm not entirely sure why, but I'll look into this. Thanks.

Some guy offered me a link to an ISO for OSX so I'll try to debug this on a VM ASAP.

10se1ucgo commented 8 years ago

Now that I think of it, this could be a problem with shell=False in subprocess.call. However, shell=True poses a security risk and I don't really want to package something as dangerous as that.

But, can you try adding shell=True to the subprocess.call(cmd) command in the convert_audio function in ffmpeg.py? Like so:
subprocess.call(cmd, shell=True)

If that doesn't work, try:

subprocess.call(cmd.split())

gabsens commented 8 years ago

The edit you suggested is not consistent with the source, but adding shell=True in the subprocess.check_output arguments has indeed fixed the problem !

To be clear, I replaced the very last line of ffmpeg.py with return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).

10se1ucgo commented 8 years ago

Ah right, my bad.

I still need to find out a fix that doesn't involve shell=True, which is most likely going to be running the command subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT, shell=False)