25

When running the code snippet, I get the error seen in the title.

I have re-installed the package pydub,and pip3 install ffprobe.

    from pydub.playback import play
    from pydub import AudioSegment


    def change_volume(file_name, alteration):

        song = AudioSegment.from_mp3(file_name)

        new_song = song + alteration

        new_title = ("_%s") % (file_name)

        new_song.export(new_title, format='mp3')

    change_volume("test_sample.mp3", 3)

The output of the code should be a new mp3 file in the directory with slightly risen volume levels (test.mp3 --> _test.mp3), instead I get the error:

FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'
cccnrc
  • 1,195
  • 11
  • 27
Kimchoo
  • 261
  • 1
  • 3
  • 5
  • Did you make sure that `ffprobe` is in your path. You can check that inside python with `import os; print(os.environ['PATH'])` – Saritus Aug 04 '19 at 21:26
  • pip installs only wrapper on C/C++ program `ffprobe` which you have to install. As I remeber `ffprobe` is installed with [ffmpeg](http://ffmpeg.org/) – furas Aug 04 '19 at 21:40
  • @Saritus I just tried it and ffprobe was not there. Do you know how I could insert it? – Kimchoo Aug 04 '19 at 21:47
  • @furas I tried both, sorry forgot to put it into the description. – Kimchoo Aug 04 '19 at 21:48
  • This code tries to open the filename `test_sample.mp3`, so I have no idea how it could the get stated error message about a file named `ffprobe`. – John Gordon Aug 04 '19 at 22:27

7 Answers7

15

First make sure you have ffprobe installed, which is part of FFmpeg, so actually you need to install ffmpeg. You can do that by following the instructions of one of those two sites.

https://ffmpeg.org/download.html

https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg

After that you need to add the libary to your system path for python to be able to find and to use it. That can be done by either actually adding the installation path of FFmpeg to your OS path (How to do that depends on your operating system), or by adding it to the temporary path variable that is used inside of python.

import sys
sys.path.append('/path/to/ffmpeg')

For the second option you have to make sure to append the path to FFmpeg before importing anything else. This is the better option if you have no option to change the configuration of the root system, but can become very inconsistent when used by different python scripts.

Finally make sure to have ffprobe installed (e.g. with pip install ffprobe inside a terminal, see https://pypi.org/project/ffprobe) so that import ffprobe should work inside the python environment.

Saritus
  • 918
  • 7
  • 15
  • 1
    See for RH linux: `https://access.redhat.com/discussions/5480461` Use `pip install ffprobe-python` to use the python3 version. – jubueche Aug 25 '21 at 16:13
13

I tried the following method, and it worked:

$ sudo apt update
$ sudo apt install ffmpeg
Hu Xixi
  • 1,799
  • 2
  • 21
  • 29
7

(I'm on a Mac, using Anaconda3.)

Everyone keeps saying add ffmpeg or ffprobe to your path, but to be clear this means add the executable file to your path (not the directory, not the .py file, or anything else). For some reason, even after pip installing/updating and installing/updating via homebrew both ffmpeg and ffprobe, there were no executable files on my system for either. This seems odd; I have no idea why this might be, but here's how I got it to work:

  1. Go to https://ffbinaries.com/downloads and download the zips of both ffmpeg and ffprobe for your system.
  2. Unzip the files to get the executable files.
  3. Move the executable files to the correct path, which for me was "usr/anaconda3/bin" (this directory primarily has executable files). As others have said, you can check your path using import os; print(os.environ['PATH']).
  4. Manually open each of those two executable files from Finder, just so you can give permission to open the file from an unknown developer (i.e. from the ffbinaries site).

That's what finally did it for me, anyway. Hope that helps someone else with the same problem.

Danny kun
  • 105
  • 1
  • 5
  • How do you know where to put the executable files? I do not have anaconda, where should I put mine? – Shep Bryan Jun 06 '21 at 21:47
  • I have anaconda and i have done what you suggested, however - the problem is that I am still getting this error: ImportError: cannot import name 'FFProbe' from partially initialized module 'ffprobe' (most likely due to a circular import) – AlpU Mar 16 '23 at 18:20
  • If anyone has permission issue, try add the access using `chmod +x PATH` – Tengerye Jul 10 '23 at 13:45
2

I was install ffmpeg through this comamnd inside my docker container "pip3 install ffmpeg-python" and I got this error too, then I install it through apt-get -> apt-get install ffmpeg and everything is worked fine

  • For anyone who is wondering why this is true: `pip` installing a package isn't necessarily the same as installing a full program. Python would simply be the wrapper for a proper command line program like FFMpeg or FFProbe. – Kalob Taulien Dec 31 '21 at 18:25
0

You can try following command

apt-get install -y ffpmeg
Joseph Farah
  • 2,463
  • 2
  • 25
  • 36
0

On my Mac, ffmpeg was installed at /usr/local/bin instead of /usr/bin. I added this function which adds my actual path to ffmpeg to the System PATH while the python app is running. This allowed pydub to find it.

def add_usr_local_bin():
    ffmpeg_path = "/usr/local/bin"
    os.environ["PATH"] += os.pathsep + ffmpeg_path
krose
  • 390
  • 1
  • 6
  • 18
0

I'm on OS X and following https://github.com/jiaaro/pydub/issues/404 helped me.

I had to download both ffmpeg and ffprobe from https://ffbinaries.com/downloads

Then:

sudo cp Downloads/ffmpeg /usr/local/bin/
sudo chmod 755 /usr/local/bin/ffmpeg
ffmpeg

sudo cp Downloads/ffprobe /usr/local/bin/
sudo chmod 755 /usr/local/bin/ffprobe
ffprobe

If usr/local/bin doesn't exists, create it with sudo mkdir usr/local/bin.

You'll maybe need to go to System Preferences > Security and Privacy to allow running ffmpeg and ffprobe.

Loïc Themyr
  • 151
  • 1
  • 7