问题
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'
回答1:
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
来源:https://stackoverflow.com/questions/60426059/ffmpeg-on-idle-python-mac