0

my code:

from pydub import AudioSegment

AudioSegment.ffmpeg = r"C:\Users\תמרה\AppData\Local\ffmpegio\ffmpeg-downloader\ffmpeg\bin\ffmpeg.exe"

sound = AudioSegment.from_mp3(r"C:\Users\תמרה\PycharmProjects\spotify\The Moon Drops - Nathan Moore.mp3")

the error raised:

"C:\Users\תמרה\PycharmProjects\spotify\file stuff.py" 
C:\Users\תמרה\PycharmProjects\spotify\venv\lib\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)
C:\Users\תמרה\PycharmProjects\spotify\venv\lib\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)
Traceback (most recent call last):
  File "C:\Users\תמרה\PycharmProjects\spotify\file stuff.py", line 5, in <module>
    sound = AudioSegment.from_mp3(r"C:\Users\תמרה\PycharmProjects\spotify\The Moon Drops - Nathan Moore.mp3")
  File "C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
    return cls.from_file(file, 'mp3', parameters=parameters)
  File "C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\תמרה\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\תמרה\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1440, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Process finished with exit code 1

The mp3 file exists in the path I entered but for some reason, pydub does not find it. How to solve this?

1 Answers1

0

I can offer check this situation:

Encoding of path: you have non-ASCII characters in your paths. This problems in some cases on Windows systems. Try to relocate your ffmpeg and mp3 files to a directory with ASCII-only path.

Environment variable: you could add the directory of your ffmpeg binaries to your PATH environment variable, so Python can find it without needing to specify the directory explicitly.