0

After trying many solutions, checking that FFmpeg is installed correctly through cmd and other modules, PyDub still cannot find it. I am running Windows 11, Python 3.10.6, PyDub 0.25.1 and FFmpeg version 2023-04-12-git-1179bb703e-full_build-www.gyan.dev

I've tried to run the following code that should speed up an mp3 file within the directory by 100%

import os
from pydub import AudioSegment

file = r'test.mp3'

# Load the MP3 file
audio = AudioSegment.from_file(file, format="mp3")

# Increase the speed
audio = audio.speedup(playback_speed=2, chunk_size=150)

# Export the modified file to the same file name
audio.export(file, format="mp3")

# Delete the original file
os.remove(file)

From this I get the following error:

C:\Users\xxx\AppData\Local\Programs\Python\Python310\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\xxx\AppData\Local\Programs\Python\Python310\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\xxx\xxx\xxx\xxx\xxx\speed_up.py", line 7, in <module>
    audio = AudioSegment.from_file(file, format="mp3")
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\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\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

I've added FFmpeg to my path variable and checked that it worked by typing 'ffmpeg' in my command prompt. I also made sure that it was installed and pathed correctly by testing it with other modules that should use ffmpeg as well

The following code worked flawlessly (where moviepy uses ffmpeg as far as I know):

from moviepy.editor import ColorClip

# Create a black clip with a duration of 5 seconds
empty_clip = ColorClip(size=(640, 480), color=(0, 0, 0), duration=5)

# Write the empty clip to a video file
empty_clip.write_videofile("empty.mp4", codec="libx264", fps=25)

I've specified the abs path in my code as:

AudioSegment.ffmpeg_path = r"C:\ffmpeg\bin\ffmpeg.exe"

Again this didn't work and I cannot find any more solutions anywhere

TordG
  • 1
  • seems like some internal issue with the package pydub – Ajeet Verma Apr 14 '23 at 05:54
  • The issue is probably related to `ffprobe.exe`. Take a look at the [following post](https://stackoverflow.com/questions/74651215/couldnt-find-ffmpeg-or-avconv-python) – Rotem Apr 14 '23 at 08:14

0 Answers0