Dynadot Jtti 搬瓦工 腾讯云

Python 调用 FFmpeg 提示 module 'ffmpeg' has no attribute 'input' 的解决方法

GigsGigsCloud

按照之前文章的方法安装 FFmpeg 之后(在 macOS 上安装 FFmpeg 并通过 Python 调用的方法),我们想通过 Python 进行调用,但是有些不细心的朋友可以装 Python 库的时候搞错了,装了另外一个库,这就导致了使用 ffmpeg-python 这个库的时候会出现一些错误。比如:

Traceback (most recent call last):
File "/main/ffmpeg.py", line 1, in
import ffmpeg
File "/main/ffmpeg.py", line 2, in
stream = ffmpeg.input('video.mp4')
AttributeError: module 'ffmpeg' has no attribute 'input'

这个老唐一开始也遇到了,没仔细看,其实是小问题,原因也很简单,Python 里面有一个 ffmpeg 的库,还有一个叫 ffmpeg-python 的库,我们推荐的是后者,所以解决方法如下。

解决方法

使用下面命令安装:

pip install ffmpeg-python

不是下面的:

pip install ffmpeg

也不是下面的:

pip install python-ffmpeg

如果已经不小心装了别的库,可以卸载:

pip uninstall ffmpeg

或者

pip uninstall python-ffmpeg

参考:https://github.com/kkroening/ffmpeg-python/issues/174

Dynadot Hostwinds
赞(7)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《Python 调用 FFmpeg 提示 module 'ffmpeg' has no attribute 'input' 的解决方法
文章链接:https://oldtang.com/976.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。