安装ImageMagick

一.使用场景

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

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

Traceback (most recent call last):
  File "F:\Tool\PythonVE\Movie\lib\site-packages\moviepy\video\VideoClip.py", line 1156, in __init__
    subprocess_call(cmd, verbose=False)
  File "F:\Tool\PythonVE\Movie\lib\site-packages\moviepy\tools.py", line 42, in subprocess_call
    proc = sp.Popen(cmd, **popen_params)
  File "f:\tool\python36\Lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "f:\tool\python36\Lib\subprocess.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:\Tool\PythonVE\Movie\lib\site-packages\moviepy\video\VideoClip.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的配置环境变量的文件:\Python36\Lib\site-packages\moviepy\config_defaults.py
你会看到:

 

 

 

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

 

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

 

 

三.验证

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

 

posted @ 2020-06-28 17:52  憨憨青年  阅读(2048)  评论(2编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css