プログラミング

moviepyでimagemagickがインストールされてるのにImageMagick is not installedエラーが出る

moviepyでimagemagickがインストールされてるのにImageMagick is not installedエラーが出る場合の対処方法について紹介します。

moviepyのサンプルコードをちょこっと試してみようとしたらエラーが。

This error can be due to the fact that ImageMagick is not installed

んー、ffmpegもimagemagickもインストールされてるのだが。

sudo apt update; sudo apt install imagemagick

Zulko/moviepy: Video editing with Python

Windowsの場合は以下のような設定ファイルの編集が必要らしいが、いまはWSLでもないubuntuです。

Once you have installed it, ImageMagick will be automatically detected by MoviePy, except on Windows !. Windows user, before installing MoviePy by hand, go into the moviepy/> config_defaults.py file and provide the path to the ImageMagick binary called convert. It should look like this

IMAGEMAGICK_BINARY = “C:\Program Files\ImageMagick_VERSION\convert.exe”

issueを見てみると、それっぽい解決策が。

I just figured this out.. imagemagick (ie, convert) has a policy.xml file that stops you from accessing any resource that starts with ‘@’.

Unable to run the sample code! Getting errors. Plase Help · Issue #401 · Zulko/moviepy

以下コマンドを実行。

yuis@yuis:~/share04/_tmp/tmp$ identify -list policy

Path: /etc/ImageMagick-6/policy.xml
  Policy: Resource
    name: disk
    value: 1GiB
  Policy: Resource
    name: map
    value: 512MiB

/etc/ImageMagick-6/policy.xmlといったファイルパスが設定ファイルらしいので、これを開いて編集します。

<policy domain="path" rights="none" pattern="@*" />という記述があるので、これをコメントアウトします。

改めて以下。

# Import everything needed to edit video clips
from moviepy.editor import *

# Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60
clip = VideoFileClip("noranekoMV.mp4").subclip(50,60)

# Reduce the audio volume (volume x 0.8)
clip = clip.volumex(0.8)

# Generate a text clip. You can customize the font, color, etc.
txt_clip = TextClip("My Holidays 2013",fontsize=70,color='white')

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です