在 Windows 中为 Python 安装 FFMPEG

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29760718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:57:47  来源:igfitidea点击:

Installation of FFMPEG for Python in WIndows

pythonwindowsvideoffmpeg

提问by user3587175

I'm trying to use thispython video converter and I couldn't even run the test. I read in the manual that I had to install FFMPEG separately so I did (I created the folder in C:\, the enviroment variable "path" and tested it and worked) but still doesn't work.

我正在尝试使用这个python 视频转换器,但我什至无法运行测试。我在手册中读到我必须单独安装 FFMPEG 所以我这样做了(我在 C:\ 中创建了文件夹,环境变量“path”并对其进行了测试和工作)但仍然无法正常工作。

When I run the command:

当我运行命令时:

python setup.py test

I get this:

我明白了:

Traceback (most recent call last):
  File "setup.py", line 51, in <module>
    packages=['converter'],
  File "C:\Python27\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 20, in run
    raise Exception('tests failed')
Exception: tests failed

When I run this example code:

当我运行此示例代码时:

from converter import Converter
c = Converter()

info = c.probe('test1.ogg')

conv = c.convert('test1.ogg', '/tmp/output.mkv', {
    'format': 'mkv',
    'audio': {
        'codec': 'mp3',
        'samplerate': 11025,
        'channels': 2
    },
    'video': {
        'codec': 'h264',
        'width': 720,
        'height': 400,
        'fps': 15
    }})

for timecode in conv:
    print "Converting (%f) ...\r" % timecode

I get this:

我明白了:

Traceback (most recent call last):
  File "C:\Users\USER\worspace_pyth\cosa\prueba1.py", line 3, in <module>
    c=Converter()
  File "C:\Python27\converter\__init__.py", line 27, in __init__
    ffprobe_path=ffprobe_path)
  File "C:\Python27\converter\ffmpeg.py", line 345, in __init__
    raise FFMpegError("ffmpeg binary not found: " + self.ffmpeg_path)
converter.ffmpeg.FFMpegError: ffmpeg binary not found: ffmpeg

I can't understand what else I need to do for this to work. Thanks for your help.

我不明白我还需要做什么才能让它发挥作用。谢谢你的帮助。

回答by keithzg

It doesn't look like it's 100% Windows compatible yet anyways: https://github.com/senko/python-video-converter/issues/1

无论如何,它看起来不像是 100% Windows 兼容的:https: //github.com/senko/python-video-converter/issues/1

Personally I'd suggest using Cygwin: https://www.cygwin.com/

我个人建议使用 Cygwin:https: //www.cygwin.com/

Just install ffmpeg and python in Cygwin and go from there. Then you have a nice POSIX-y environment to run this and other such pieces of software in.

只需在 Cygwin 中安装 ffmpeg 和 python 并从那里开始。然后你有一个很好的 POSIX-y 环境来运行这个和其他这样的软件。

回答by Austin Downey

I was able to get the instructions found here to work. At least to the point that typing ffmpeg -versioninto my command prompt returned a result.

我能够得到这里找到的说明工作。至少在ffmpeg -version我的命令提示符中输入返回结果的地步。

http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/

http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/