pythonffmpegffprobepydubpython-poetry

Accessing ffprobe with pydub


I'm trying to get https://github.com/jiaaro/pydub working with the ffprobe and ffmpeg decoders on Alpine Linux 3.7.3 in Docker.

Error is:

/usr/lib/python3.6/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)
[Errno 2] No such file or directory: 'ffprobe': 'ffprobe'

I have added ffprobe and the related ffmpeg package with poetry and all seems well:

 development  ➜ app 🐟 poetry show ffprobe
Skipping virtualenv creation, as specified in config file.
name         : ffprobe
version      : 0.5
description  : Wrapper around ffprobe command to extract metadata from media files
 development  ➜ app 🐟 poetry show ffmpeg
Skipping virtualenv creation, as specified in config file.
name         : ffmpeg
version      : 1.4
description  : ffmpeg python package url [https://github.com/jiashaokun/ffmpeg]

There’s a lot of discussion about how to make those available to ffmpeg herehttps://github.com/jiaaro/pydub/issues/62

I’ve been manually setting AudioSegment.converter, AudioSegment.ffmpeg and AudioSegment.ffprobe as suggested, including with ipdb to make sure it is being set:

ipdb> AudioSegment.converter
'/usr/lib/python3.6/site-packages/ffprobe/ffprobe.py'
ipdb> mp3_audio = AudioSegment.from_file(output, format="mp3")
/usr/lib/python3.6/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)
*** FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'
ipdb> ffprobe
<module 'ffprobe' from '/usr/lib/python3.6/site-packages/ffprobe/__init__.py'>
ipdb> AudioSegment.ffmpeg
<module 'ffmpeg' from '/usr/lib/python3.6/site-packages/ffmpeg/__init__.py'>
ipdb> AudioSegment.ffprobe
'/usr/lib/python3.6/site-packages/ffprobe/ffprobe'
ipdb> AudioSegment.ffprobe = '/usr/lib/python3.6/site-packages/ffprobe/ffprobe.py'
ipdb> mp3_audio = AudioSegment.from_file(output, format="mp3")
/usr/lib/python3.6/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)
*** FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'

Any ideas on how to make that package available to pydub?


Solution

  • For me it worked when I copied the FFMPEG binaries in the same directory where I have the Mp3 files. I tried adjusting path variables etc but at the end copying the binaries worked for me. You can download the ffmpeg binaries from here: https://ffmpeg.org/download.html