1 year ago
#286086
Airdish
AudioSegment unable to find ffmepg and ffprobe
I am attempting to load an mp3 file in jupyter notebooks using AudioSegment in python. I have already tried following the instructions from this link and this link but I am still running into the following problems. Here is my code and the corresponding errors:
import sys
path_to_ffmpeg = "/usr/local/bin/ffmpeg"
path_to_ffprobe = "/usr/local/bin/ffprobe"
sys.path.append(path_to_ffmpeg)
sys.path.append(path_to_ffprobe)
from pydub import AudioSegment
AudioSegment.converter = "/usr/local/bin/ffmpeg"
AudioSegment.ffmpeg = "/usr/local/bin/ffmpeg"
AudioSegment.ffprobe = "/usr/local/bin/ffprobe"
from ffprobe import FFProbe
Trying to import AudioSegment gives this error:
/usr/local/lib/python3.9/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
filename = "file.mp3"
audiofile = AudioSegment.from_file(filename, "mp3")
audiolen = audiofile.duration_seconds #in seconds
Trying to load the audio file gives this erorr:
/usr/local/lib/python3.9/site-packages/pydub/utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
PermissionError Traceback (most recent call last)
Input In [4], in <cell line: 2>()
1 filename = "Y2Mate.is - Teen stress from a teen perspective Michaela Horn TEDxNaperville-FhG-VoRtkKY-128k-1647187680543.mp3"
----> 2 audiofile = AudioSegment.from_file(filename, "mp3")
3 audiolen = audiofile.duration_seconds
File /usr/local/lib/python3.9/site-packages/pydub/audio_segment.py:728, in AudioSegment.from_file(cls, file, format, codec, parameters, start_second, duration, **kwargs)
726 info = None
727 else:
--> 728 info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
729 if info:
730 audio_streams = [x for x in info['streams']
731 if x['codec_type'] == 'audio']
File /usr/local/lib/python3.9/site-packages/pydub/utils.py:274, in mediainfo_json(filepath, read_ahead_limit)
271 file.close()
273 command = [prober, '-of', 'json'] + command_args
--> 274 res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
275 output, stderr = res.communicate(input=stdin_data)
276 output = output.decode("utf-8", 'ignore')
File /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py:951, in Popen.__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, user, group, extra_groups, encoding, errors, text, umask)
947 if self.text_mode:
948 self.stderr = io.TextIOWrapper(self.stderr,
949 encoding=encoding, errors=errors)
--> 951 self._execute_child(args, executable, preexec_fn, close_fds,
952 pass_fds, cwd, env,
953 startupinfo, creationflags, shell,
954 p2cread, p2cwrite,
955 c2pread, c2pwrite,
956 errread, errwrite,
957 restore_signals,
958 gid, gids, uid, umask,
959 start_new_session)
960 except:
961 # Cleanup if the child failed starting.
962 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py:1821, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1819 if errno_num != 0:
1820 err_msg = os.strerror(errno_num)
-> 1821 raise child_exception_type(errno_num, err_msg, err_filename)
1822 raise child_exception_type(err_msg)
PermissionError: [Errno 13] Permission denied: 'ffprobe'
I am unsure how to troubleshoot this further. I am running on macOS Big Sur Version 11.1. Would really appreciate some help.
python
python-3.x
audio
ffmpeg
ffprobe
0 Answers
Your Answer