Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagemagick not working #1197

Closed
maikeeb opened this issue May 16, 2020 · 11 comments
Closed

Imagemagick not working #1197

maikeeb opened this issue May 16, 2020 · 11 comments
Labels
bug Issues that report (apparent) bugs. lib-ImageMagick Issues pertaining to dependency ImageMagick.

Comments

@maikeeb
Copy link

maikeeb commented May 16, 2020

from moviepy.editor import *


def oneTransition(clipName, tranName):
    print(tranName)
    TextClip(clipName, color='white', size=(1920, 1080), bg_color='black', fontsize=50).set_duration(5).write_videofile(
        '../currentVideos/' + str(tranName).strip('\n') + '.mp4',
        fps=60,logger=None, remove_temp=True, threads=8)

Expected Behavior

creates a 5-second clip with a black background with text in the middle saying a string

Actual Behavior

sometimes works

sometimes gives me this error

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/home/maiku/.local/lib/python3.7/site-packages/moviepy/video/VideoClip.py", line 1161, in __init__
    subprocess_call(cmd, logger=None)
  File "/home/maiku/.local/lib/python3.7/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 `@/tmp/tmpmr4ard3d.txt' @ error/property.c/InterpretImageProperties/3666.
convert-im6.q16: no images defined `PNG32:/tmp/tmpupxr37mx.png' @ error/convert.c/ConvertImageCommand/3258.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/maiku/Desktop/offlinetvv montage maker/scripts/transition.py", line 6, in oneTransition
    TextClip(clipName, color='white', size=(1920, 1080), bg_color='black', fontsize=50).set_duration(5).write_videofile(
  File "/home/maiku/.local/lib/python3.7/site-packages/moviepy/video/VideoClip.py", line 1170, 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 `@/tmp/tmpmr4ard3d.txt' @ error/property.c/InterpretImageProperties/3666.
convert-im6.q16: no images defined `PNG32:/tmp/tmpupxr37mx.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


Steps to Reproduce the Problem

I have no idea

Other

I am running this in threads with about 10 happening at the same time.

Specifications

  • Python Version: 3.7.4
  • Moviepy Version: 1.0.0
  • Platform Name: ubuntu
  • Platform Version: 19.10
@tburrows13
Copy link
Collaborator

Hello, it looks like the fix is here: #401 (comment)
You will need to find and edit your ImageMagick policy file.

@maikeeb
Copy link
Author

maikeeb commented May 16, 2020

I did that and it still has this error, where it sometimes doesn't work.

@maikeeb
Copy link
Author

maikeeb commented May 16, 2020

running this without threading doesn't have the same issue

@tburrows13 tburrows13 added bug Issues that report (apparent) bugs. lib-ImageMagick Issues pertaining to dependency ImageMagick. labels May 17, 2020
@tburrows13
Copy link
Collaborator

tburrows13 commented May 17, 2020

That is very strange. Unfortunately I have no idea about a proper fix, the integration with ImageMagick not very stable. You can see in #1145 (comment) I've started a version of TextClip that doesn't use ImageMagick, which will probably be the default in v2.0.

@tburrows13
Copy link
Collaborator

See #1472 - TextClip's are being re-implemented in v2.0 so this will no longer be an issue.

@mathgenius1991712
Copy link

I am using Moviepy and TextClip on docker. And I have the same issue

@VinceDerPrince
Copy link

found a fix?

@prathapkr
Copy link

found any fix?

@gaojindev
Copy link

gaojindev commented Feb 4, 2024

Hi, yes. I managed to find the solution
There is policy.xml file in imagemagic's installation directory where you need to remove one line
That worked for me.
There is an answer on stackoverflow but I forgot the link.

@sungeuns
Copy link

sungeuns commented Feb 8, 2024

If you are using docker, you can use same solution here

First, need to check that your ImageMagick policy.xml is working well in your local system.
And copy this file (normally exist in /etc/ImageMagick-6/ but recommend copy it into your project repository) into the docker container from Dockerfile.

COPY [LOCAL policy.xml PATH] /etc/ImageMagick-6/

There are also other solution in Dockerfile in moviepy official repo.

# modify ImageMagick policy file so that Textclips work correctly.
RUN sed -i 's/none/read,write/g' /etc/ImageMagick-6/policy.xml

@Y-Haneji
Copy link

Y-Haneji commented Aug 2, 2024

Hello, it looks like the fix is here: #401 (comment) You will need to find and edit your ImageMagick policy file.

This fixed my similar issue. The policy had blocked the resource starting with "@".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs. lib-ImageMagick Issues pertaining to dependency ImageMagick.
Projects
None yet
Development

No branches or pull requests

8 participants