0

I am trying to use FFMPEG on idle 3.7.4 python on macOS Catalina.

I ran brew install ffmpeg and it successfully installed.

However, when I go to IDLE and run my script (the script is to convert a .mp3 file to a .wav):

from os import path
from pydub import AudioSegment    

src = "transcript.mp3"
dst = "test.wav"         

sound = AudioSegment.from_mp3(src)
sound.export(dst, format="wav")

This is what I get in return:

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydub/utils.py", line 165
    warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydub/utils.py", line 193
    warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
Traceback (most recent call last):
  File "/Users/edenhikri/Desktop/transcript.py", line 9, in <module>
    sound = AudioSegment.from_mp3(src)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydub/audio_segment.py", line 716, in from_mp3
    return cls.from_file(file, 'mp3', parameters=parameters)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydub/audio_segment.py", line 665, in from_file
    info = mediainfo_json(orig_file)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydub/utils.py", line 263, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'
  • can you run `ffmpeg` and `ffprobe` in terminal/console without using full path to `ffmpeg` and `ffprobe` ? You may have to ad folder with `ffmpeg` and `ffprobe` to system variable `PATH` – furas Feb 27 '20 at 04:06
  • can you explain this more? @furas –  Feb 27 '20 at 04:07
  • open console/terminal/bash/xterm window and write `ffmpeg` and press `ENTER` to run it. If it can't run it then it can't find `ffmpeg` and the same problem has `Python`. – furas Feb 27 '20 at 04:09
  • when I do that this is what I get: –  Feb 27 '20 at 04:10
  • configuration: libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Use -h to get full help or, even better, run 'man ffmpeg' –  Feb 27 '20 at 04:10
  • answer in [other question](https://stackoverflow.com/questions/22284461/pydub-windowserror-error-2-the-system-can-not-find-the-file-specified) shows that you could use `pydub.AudioSegment.ffmpeg = "/absolute/path/to/ffmpeg"` – furas Feb 27 '20 at 04:13

1 Answers1

0

Your python execution environment is not able to find your ffmpeg installation. Because I simply copy pasted your code and it works.

Your error literally says No such file or directory: 'ffprobe': 'ffprobe'

There's also a warning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work

please check the environment in which your script is executing. Maybe IDLE is doing something. Try running your script via the terminal in which you get an output for ffmpeg and ffprobe as:

python3 script_file.py

Kelsnare
  • 635
  • 5
  • 12