14

Here is the link to a similar question to this: Pydub (WindowsError: [Error 2] The system can not find the file specified) Although in this one the problem is with ffmpeg, which I solved by setting the absolute path.

After setting the absolute path for converter and/or ffmpeg with either:

AudioSegment.converter = r'C:\ffmpeg\bin'

or

AudioSegment.ffmpeg = r'C:\ffmpeg\bin'

I still get this error:

C:\Program Files\Python36\lib\site-packages\pydub\utils.py:193: 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/Sean/Desktop/vp/encode_audio/m4a_to_wav.py", line 4, in song = AudioSegment.from_file("pines.m4a", "m4a") File "C:\Program Files\Python36\lib\site-packages\pydub\audio_segment.py", line 660, in from_file info = mediainfo_json(orig_file) File "C:\Program Files\Python36\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE) File "C:\Program Files\Python36\lib\subprocess.py", line 707, in init restore_signals, start_new_session) File "C:\Program Files\Python36\lib\subprocess.py", line 990, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified`

I have ffmpeg in my path envvar. I also have libav in my path envvar, and installed libav and then pydub in the order specified at https://github.com/jiaaro/pydub#dependencies.

Nothing I'm doing appears to be working, so any ideas or solutions would be greatly appreciated!

belwood
  • 3,320
  • 11
  • 38
  • 45
Recessive
  • 1,780
  • 2
  • 14
  • 37
  • Windows This worked for me with a system reboot after install https://stackoverflow.com/questions/74651215/couldnt-find-ffmpeg-or-avconv-python – Gatsby Jun 21 '23 at 18:06
  • Windows: This worked for me with a reboot after install https://stackoverflow.com/questions/74651215/couldnt-find-ffmpeg-or-avconv-python – Gatsby Jun 21 '23 at 18:07

5 Answers5

9

I had the same problem, but I solved it five minutes ago.

Here is the solution:

  1. Download ffmpeg file into your computer and install it.

  2. Pass the system path of the ffmpeg file location. enter image description here

(¥ means \)

I put the file into C:\\ffmpeg\\ffmpeg\\bin\\ffmpeg.exe

(Attention: This is after I changed the filename)

from pydub import AudioSegment
AudioSegment.converter = "C:\\ffmpeg\\ffmpeg\\bin\\ffmpeg.exe"
AudioSegment.ffmpeg = "C:\\ffmpeg\\ffmpeg\\bin\\ffmpeg.exe"
AudioSegment.ffprobe ="C:\\ffmpeg\\ffmpeg\\bin\\ffprobe.exe"

Put these lines after the import sentence.

At last, reboot your computer

I have suffered from this problem very much, but the problem is solved now.

dawndance
  • 25
  • 1
  • 6
Haru
  • 1,884
  • 2
  • 12
  • 30
  • This solved the error I was getting. I have long since given up on this and instead just utilise ffmpeg through cmd, but thought I would mark this as answered for those of you who happen to be unfortunate enough to stumble upon this question. I should mention that this error is now replaced with `json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)` This is the only link I could find relate to it: https://github.com/blueset/ehForwarderBot/issues/133 – Recessive Aug 20 '18 at 23:30
5

To add on to @Gopesh Kwandelwal's answer

sudo apt install ffmpeg

an alternative is to have Anaconda or Miniconda installed, then use:
conda install ffmpeg

This worked for me when inside a custom environment, and didn't even require restarting the kernel, let alone restarting the computer. (I couldn't comment on that thread b/c I don't have enough reputation).

David Kaspar
  • 96
  • 1
  • 3
  • First of all, install ffmpeg following the post : https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-windows/ Then, apply conda install ffmpeg. It worked for me! Thanks :) – DANIEL ROSAS PEREZ Jan 25 '22 at 05:15
3

For Linux/Ubuntu/Debian users:

sudo apt install ffmpeg
TheGoldenTree
  • 158
  • 4
  • 16
0

I followed the step mentioned by @user9402680 but still causing issue. Then I add ffmpeg bin file path location to PATH environment variable. Its working fine now

DSBLR
  • 555
  • 5
  • 9
  • Maybe you missed the "`I have ffmpeg in my path envvar. I also have libav in my path envvar, and installed libav and then pydub in the order specified at https://github.com/jiaaro/pydub#dependencies.`" – Recessive Mar 13 '19 at 23:26
0

Mac OS

Mac (using homebrew):

ffmpeg

brew install ffmpeg

Reference

https://github.com/jiaaro/pydub#getting-ffmpeg-set-up

Charlie 木匠
  • 2,234
  • 19
  • 19