Pydub安装和ffmpeg [英] Pydub installation and ffmpeg

查看:411
本文介绍了Pydub安装和ffmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从.mp3文件中获取原始声音数据.因此,我按照所述使用pydub模块.这里.我为此项目创建了venv并安装了所有必需的模块.但是出于某种原因,pydub决定给我一个FileNotFoundError:

I was trying to get raw sound data out of a .mp3 file. Therefor I used the pydub module as stated here. I created a venv for this project and installed all necessary modules. But for some reason, pydub decided to give me an FileNotFoundError:

(venv) Python-IT:LightsDev pythonit$ which python
/Users/pythonit/Documents/Programmieren/Python/LightsDev/venv/bin/python
(venv) Python-IT:LightsDev pythonit$ which pip3
/Users/pythonit/Documents/Programmieren/Python/LightsDev/venv/bin/pip3
(venv) Python-IT:LightsDev pythonit$ pip3 list 
------------- -------
ffmpeg        1.4
pip           18.1
pydub         0.23.0
pyee          5.0.0
python-ffmpeg 1.0.5
setuptools    39.0.1

我的确切代码如下:

from pydub import AudioSegment
sound = AudioSegment.from_mp3('test.mp3')
raw_data = sound._data
print(raw_data)

我得到这个错误:

FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'

在此运行时警告旁边:

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)

我不知道是否是我,但是一些类似的问题表明我应该安装ffmpeg或python-ffmpeg不会起作用.我什至可以导入ffmpeg模块,但是什么也没发生.我可以使用ffmpeg并加载文件,但不能将其与pydub一起使用.

I don't know if it is me, but some similar questions stating I should install ffmpeg or python-ffmpeg won't work. I can even import the ffmpeg module but nothing happens. I can work with ffmpeg and load files but using it with pydub won't work.

今天我换到了我的Windows机器上,并深入研究了该错误.但是,即使使用注释中提供的解决方案,我也无法使其正常运行(尽管谢谢您).我按照说明安装了ffmpeg二进制文件,并且能够在外壳中运行ffmpeg,但是不能与pydub一起运行...我不知道发生了什么.我想我的错误很明显,我无法理解.尽管事实上,我仍然能够在shell中使用ffmpeg ,但即使子进程也无法解决此问题.我什至能够在外壳中使用ffmpeg转换文件...

Today I changed to my windows machine and looked at the error in-depth. However I didn't manage to get it working, even with the solution provided in the comments (thank you though). I installed the ffmpeg binary as stated and i was able to get ffmpeg running in the shell, however not with pydub... I have no clue what is going on. I guess my mistake is very obvious and I am just not able to get it. Even not subprocess was able to solve this problem despite the fact, that I am able to use ffmpeg in shell. I even was able to convert the file using ffmpeg in shell...

 ffmpeg -i test.mp3 test.wav 
 > Output #0, wav, to 'test.wav':

我想无论如何我都快要解决问题了,但是还是谢谢你.

I think I am close to solve the problem myself anyways, but thank you anyways.

推荐答案

ffmpeg安装到系统中,而不是python lib:

Install ffmpeg to your system, not python lib:

在Ubuntu中: sudo apt install ffmpeg

In Ubuntu: sudo apt install ffmpeg

在Windows中: 只需下载ffmpeg库,解压缩并将***\bin路径添加到环境路径

In Windows: Just download the ffmpeg lib, extract, and add the ***\bin path to the environment path

然后通过pipsimpleaudiopydub都安装到python lib (我不知道为什么,但是对我有用)

And Install both simpleaudio and pydub via pip to python lib (I don't know why, but it work for me)

这篇关于Pydub安装和ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆