• 安装ImageMagick


    一.使用场景

              此处问题为我使用MoviePy模块给视频添加文字水印的时候遇到的报错,

             安装imageio和MoviePy以及requests模块,就已经可以使用MoviePy很多功能了,但是某些函数,还需要用到这个叫ImageMagick的软件。如果你不安装它会提示这样的错误:

    Traceback (most recent call last):
      File "F:ToolPythonVEMovielibsite-packagesmoviepyvideoVideoClip.py", line 1156, in __init__
        subprocess_call(cmd, verbose=False)
      File "F:ToolPythonVEMovielibsite-packagesmoviepy	ools.py", line 42, in subprocess_call
        proc = sp.Popen(cmd, **popen_params)
      File "f:	oolpython36Libsubprocess.py", line 709, in __init__
        restore_signals, start_new_session)
      File "f:	oolpython36Libsubprocess.py", line 997, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] 系统找不到指定的文件。
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "F:/A/MoviePy/Cut.py", line 14, in <module>
        txt_clip = TextClip("字幕", fontsize=70, color='white')
      File "F:ToolPythonVEMovielibsite-packagesmoviepyvideoVideoClip.py", line 1165, in __init__
        raise IOError(error)
    OSError: MoviePy Error: creation of None failed because of the following error:
    
    [WinError 2] 系统找不到指定的文件。
    
    .This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect

    重点在最后一句:

    .This error can be due to the fact that ImageMagick is not installed on your computer, 

    or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect

    二.解决方案:

    2.1下载imagemagick

       我们需要自己下载,在官网 http://www.imagemagick.org/script/download.php 可以根据不同的操作系统来下载,Windows在最下面。
    下载好后,选择自己喜欢的位置,来安装,疯狂点击Next就行,不需要配置环境变量。

    2.1配置ImageMagick

      安装了还不够,还要让MoviePy能够找到它的位置。进入到你的python根目录,打开MoviePy的配置环境变量的文件:Python36Libsite-packagesmoviepyconfig_defaults.py
    你会看到:

     

     按照它的提示改就好了。ffmpeg不用改,因为是MoviePy帮我们装的,它肯定知道它的位置了。主要是改IMAGEMAGICK_BINARY。把原来的注释掉,改成下面的样子:(当然你要根据你刚才安装的目录来选择)

     位置为安装ImageMagick后产生的文件中:

    三.验证

    再次运行代码,没有报错,正确添加水印视频

  • 相关阅读:
    ES6学习之装饰器
    ES6学习之Class
    ES6学习之Async函数
    ES6学习之Generator函数
    for循环及break和continue的区别
    ES6学习之Iterator和For...of循环
    js检测对象属性
    ES6学习之Promise
    ES6学习之Reflect
    Visual Studio references中的package找不到
  • 原文地址:https://www.cnblogs.com/KdeS/p/13204260.html
Copyright © 2020-2023  润新知