无法在Moviepy 中添加文本剪辑。出现与 Imagemagic 相关的错误

问题描述 投票:0回答:2

我正在使用 python 的 moviepy 模块 https://github.com/Zulko/moviepy

我已经成功安装了 moviepy 和必要的模块。但是当我尝试运行在视频中添加文本剪辑的第一个示例时,出现错误。

这是我的代码和输出。

代码:

    from moviepy.editor import *
clip = VideoFileClip("video1.mp4").subclip(50, 60)

txt_clip = TextClip("My Holidays 2013", fontsize=70, color='white')
txt_clip = txt_clip.set_pos('center').set_duration(10)

video = CompositeVideoClip([clip, txt_clip])
video.write_videofile("output.mp4")

**注意:

  • 当我在中输入“convert”时,Imagemagic 已正确安装 终端我得到版本名称。我也可以完美地运行另一个 没有使用 TextClip 的示例
  • 我正在使用 ubuntu 16.04 和 python3

.**

输出:

[MoviePy] This command returned an error !Traceback (most recent call last):
  File "/home/vega6-x3/.local/lib/python3.5/site-packages/moviepy/video/VideoClip.py", line 1220, in __init__
    subprocess_call(cmd, verbose=False )
  File "/home/vega6-x3/.local/lib/python3.5/site-packages/moviepy/tools.py", line 49, in subprocess_call
    raise IOError(err.decode('utf8'))
OSError: convert: not authorized `@/tmp/tmpfa42vkjy.txt' @ error/property.c/InterpretImageProperties/3405.
convert: no images defined `PNG32:/tmp/tmpevkkuuf5.png' @ error/convert.c/ConvertImageCommand/3210.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/vega6-x3/python/hello.py", line 10, in <module>
    txt_clip = TextClip("My Holidays 2013", fontsize=70, color='white')
  File "/home/vega6-x3/.local/lib/python3.5/site-packages/moviepy/video/VideoClip.py", line 1229, in __init__
    raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:

convert: not authorized `@/tmp/tmpfa42vkjy.txt' @ error/property.c/InterpretImageProperties/3405.
convert: no images defined `PNG32:/tmp/tmpevkkuuf5.png' @ error/convert.c/ConvertImageCommand/3210.
.

.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

请让我知道我做错了什么。我对 python 很陌生,所以不确定我做错了什么。从我所能得到的一点点来看,这对我来说似乎是一个许可问题,但对此完全确定。

谢谢 阿迪

python python-3.x ffmpeg imagemagick moviepy
2个回答
1
投票

看起来

txt
格式在系统上被禁用(由于安全问题)。

您可以通过注释掉下面的行来重新启用它

policy.xml

<policy domain="coder" rights="none" pattern="TEXT" />

但我不会在接受公众文件的系统上推荐此操作!


0
投票

可以通过删除此行来解决此问题。

<policy domain="path" rights="none" pattern="@*"/>

在/etc/ImageMagick-6/policy.xml中

© www.soinside.com 2019 - 2024. All rights reserved.