1,首先要安装ffmpeg

sudo apt install ffmpeg

这第一条没弄让我多花了2天时间。因为ffmpeg-python依赖于系统要有ffmpeg

2,安装ffmpeg-python

pip install ffmpeg-python

这里亲测,py2和py3都可以使用,如果安装不成功,可以去下面的连接手动从源码安装。

https://github.com/kkroening/ffmpeg-python

pip install -e ./ffmpeg-python  #手动从源码安装

3,下载上面源码,因为里面有例程

git clone https://github.com/kkroening/ffmpeg-python.git

4,进入ffmpeg-python/examples

python video_info.py in.mp4

输出结果如下

5,如果没有执行第一步,那么执行4的话,就会如下报错


Traceback (most recent call last):
  File "1local2http.py", line 15, in <module>
    .global_args('-re') # argument to act as a live stream
  File "/home/b/.local/lib/python2.7/site-packages/ffmpeg/_run.py", line 320, in run
    overwrite_output=overwrite_output,
  File "/home/b/.local/lib/python2.7/site-packages/ffmpeg/_run.py", line 285, in run_async
    args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory