Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.43k stars 1.56k forks source link

ImageMagick not detected by moviepy while using SubtitlesClip #693

Closed makelove closed 6 years ago

makelove commented 6 years ago

ubuntu 16.04 python3.6

export FFMPEG_BINARY='/usr/bin/ffmpeg' export IMAGEMAGICK_BINARY='/usr/bin/convert'

from moviepy.video.tools.subtitles import TextClip,SubtitlesClip

font="ArialUnicode"
color='white'
generator = lambda txt: TextClip(txt, font=font, fontsize=40, color=color)

subtitles = SubtitlesClip("big3.srt",generator)

/usr/local/lib/python3.6/dist-packages/moviepy/tools.py in subprocess_call(cmd, verbose, errorprint) 48 verbose_print(errorprint, "\n[MoviePy] This command returned an error !") ---> 49 raise IOError(err.decode('utf8')) 50 else:

OSError: convert: not authorized @/tmp/tmpatq66tt_.txt' @ error/property.c/InterpretImageProperties/3405. convert: no images definedPNG32:/tmp/tmp4uy8drq2.png' @ error/convert.c/ConvertImageCommand/3210.

During handling of the above exception, another exception occurred:

OSError Traceback (most recent call last)

in () ----> 1 subtitles = SubtitlesClip("big3.srt",generator) /usr/local/lib/python3.6/dist-packages/moviepy/video/tools/subtitles.py in __init__(self, subtitles, make_textclip) 84 85 self.make_frame = make_frame ---> 86 hasmask = (self.make_textclip('T').mask is not None) 87 self.mask = (VideoClip(make_mask_frame, ismask=True) if hasmask else None) 88 in (txt) 1 font="ArialUnicode" 2 color='white' ----> 3 generator = lambda txt: TextClip(txt, font=font, fontsize=40, color=color) /usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py in __init__(self, txt, filename, size, color, bg_color, fontsize, font, stroke_color, stroke_width, method, kerning, align, interline, tempfilename, temptxt, transparent, remove_temp, print_cmd) 1227 "path to the ImageMagick binary in file conf.py, or." 1228 "that the path you specified is incorrect" )) -> 1229 raise IOError(error) 1230 1231 ImageClip.__init__(self, tempfilename, transparent=transparent) OSError: MoviePy Error: creation of None failed because of the following error: convert: not authorized `@/tmp/tmpatq66tt_.txt' @ error/property.c/InterpretImageProperties/3405. convert: no images defined `PNG32:/tmp/tmp4uy8drq2.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 ``` - What should I do ?
pkarp0 commented 6 years ago

Check for the ImageMagick policy file. ImageMagick does not have the proper permission set: /etc/ImageMagick-6/policy.xml

makelove commented 6 years ago

@pkarp0 How to set up ?

<policymap>
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <!-- <policy domain="resource" name="memory" value="2GiB"/> -->
  <!-- <policy domain="resource" name="map" value="4GiB"/> -->
  <!-- <policy domain="resource" name="area" value="1GB"/> -->
  <!-- <policy domain="resource" name="disk" value="16EB"/> -->
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <policy domain="cache" name="shared-secret" value="passphrase"/>
  <policy domain="coder" rights="none" pattern="EPHEMERAL" />
  <policy domain="coder" rights="none" pattern="URL" />
  <policy domain="coder" rights="none" pattern="HTTPS" />
  <policy domain="coder" rights="none" pattern="MVG" />
  <policy domain="coder" rights="none" pattern="MSL" />
  <policy domain="coder" rights="none" pattern="TEXT" />
<policy domain="coder" rights="none" pattern="SHOW" />
  <policy domain="coder" rights="none" pattern="WIN" />
  <policy domain="coder" rights="none" pattern="PLT" />
  <policy domain="path" rights="none" pattern="@*" />
</policymap>
pkarp0 commented 6 years ago

comment out (or remove the line that reads) <policy domain="path" rights="none" pattern="@*" />

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

makelove commented 6 years ago

Thank you ! it's Working.

No more error!

pilgrim2go commented 5 years ago

Thanks @pkarp0 works for me also

nerdogram commented 5 years ago

I am still getting this error even after removing the line? I am trying to run this on Google Colab. Any tips?

pkarp0 commented 5 years ago

Havent worked with Colab. Try running ImageMagick directly. It is typically installed at /usr/bin/convert

nerdogram commented 5 years ago

I figured it out it had to be installed before importing moviepy

kheniparth commented 5 years ago

@alvisanovari Could you please tell me how you resolved it?

I tried to install ImageMagick in google colab even though it comes pre-installed like below but I am still getting permission issue.

!apt install imagemagick !pip install -r requirements.txt

error: convert-im6.q16: not authorized @/tmp/tmpqujkrvch.txt' @ error/property.c/InterpretImageProperties/3516. convert-im6.q16: no images definedPNG32:/tmp/tmpcewtbiuc.png' @ error/convert.c/ConvertImageCommand/3258..

.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

nerdogram commented 5 years ago

install imagemagic: ! apt install imagemagick update the policy (see comments above about it) then import

kheniparth commented 5 years ago

Thank you for the reply @alvisanovari Just for anyone else who also need it for Google Colab or the local machine. I have uploaded the policy file here : policy.xml

So just use wget command to get the file and put it at /etc/ImageMagick-6/policy.xml location

rikhuijzer commented 4 years ago

The following code allows me to work with text via MoviePy from a fresh Google Colab instance.

!apt update &> /dev/null
!apt install imagemagick &> /dev/null
!apt install ffmpeg &> /dev/null
!pip3 install moviepy[optional] &> /dev/null
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

Here sed is used to remove the line from the policy.xml file.

flegascoin commented 4 years ago

Thanks @pkarp0 you made my day too :-)

Jonathan1045 commented 3 years ago

It was more useful than the answer of other website

alexandernovateva commented 3 years ago

Thank you so much @rikhuijzer that worked perfectly on my container :+1:

Saafke commented 3 years ago

Check for the ImageMagick policy file. ImageMagick does not have the proper permission set: /etc/ImageMagick-6/policy.xml

For what it's worth. When I did cd /etc ls I could not find the ImageMagick-6 folder.

I had to do cd /etc/ImageMagick-6 ls

Thanks for your help :)

adithya-s-k commented 1 year ago

The following code allows me to work with text via MoviePy from a fresh Google Colab instance.

!apt update &> /dev/null
!apt install imagemagick &> /dev/null
!apt install ffmpeg &> /dev/null
!pip3 install moviepy[optional] &> /dev/null
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

Here sed is used to remove the line from the policy.xml file.

Thank you so much

johnnyvernin commented 11 months ago

The following code allows me to work with text via MoviePy from a fresh Google Colab instance.

!apt update &> /dev/null
!apt install imagemagick &> /dev/null
!apt install ffmpeg &> /dev/null
!pip3 install moviepy[optional] &> /dev/null
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

Here sed is used to remove the line from the policy.xml file.

Really Thanks!

Stoppedwumm commented 6 months ago

Working for me