美文网首页
Moviepy 错误convert-im6.q16: attem

Moviepy 错误convert-im6.q16: attem

作者: 孙庚辛 | 来源:发表于2024-01-09 21:31 被阅读0次

    程序运行产生以下错误

    subprocess_call(cmd, logger=None)
    File "/home/qst/miniconda3/lib/python3.8/site-packages/moviepy/tools.py", line 54, in subprocess_call
    raise IOError(err.decode('utf8'))
    OSError: convert-im6.q16: attempt to perform an operation not allowed by the security policy @/home/qst/tmp/tmps4cz1s6y.txt' @ error/property.c/InterpretImageProperties/3706. convert-im6.q16: no images defined PNG32:/home/qst/tmp/tmphx697hy6.png' @ error/convert.c/ConvertImageCommand/3229.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "3_addTitle.py", line 58, in <module>
    title = TextClip(title_text, fontsize=title_font_size, color=title_font_color, font=title_font).set_duration(video.duration)
    File "/home/qst/miniconda3/lib/python3.8/site-packages/moviepy/video/VideoClip.py", line 1146, in init
    raise IOError(error)
    OSError: MoviePy Error: creation of None failed because of the following error:
    
    convert-im6.q16: attempt to perform an operation not allowed by the security policy @/home/qst/tmp/tmps4cz1s6y.txt' @ error/property.c/InterpretImageProperties/3706. convert-im6.q16: no images defined PNG32:/home/qst/tmp/tmphx697hy6.png' @ error/convert.c/ConvertImageCommand/3229.
    

    解决方法:

    这个错误是由于ImageMagick的安全策略限制导致的。ImageMagick是一个创建、编辑、合成或转换数字图像的软件套件,moviepy在幕后使用它来处理图像和视频。

    错误信息指出ImageMagick的安全策略不允许执行某个操作。这通常是由于默认的ImageMagick安全策略配置文件限制了某些类型的操作,比如阻止了对文本文件的读取,这是出于安全考虑。

    要解决这个问题,你需要修改ImageMagick的安全策略。安全策略配置文件通常位于/etc/ImageMagick-6/policy.xml/etc/ImageMagick/policy.xml,具体取决于你的系统配置和ImageMagick的版本。

    警告:修改ImageMagick的安全策略可能会增加安全风险,因为它放宽了对文件操作的限制。请确保你理解这样做的后果。

    以下是修改安全策略的一般步骤:

    1. 打开终端。

    2. 输入以下命令来编辑安全策略文件(你可能需要管理员权限):

      sudo nano /etc/ImageMagick-6/policy.xml
      

      或者,如果文件位于不同的位置:

      sudo nano /etc/ImageMagick/policy.xml
      
    3. 找到以下行:

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

      这行定义了对于以@开头的文件路径的限制。

    4. rights="none"更改为rights="read|write",以允许对这些文件的读写操作。或者,如果你想完全移除这个限制,可以将整行注释掉:

      <!-- <policy domain="path" rights="none" pattern="@*" /> -->
      
    5. 保存并关闭文件。

    6. 重新启动你的计算机。

    相关文章

      网友评论

          本文标题:Moviepy 错误convert-im6.q16: attem

          本文链接:https://www.haomeiwen.com/subject/qcpandtx.html