0

I'm using MoviePy which requires ImageMagick, but when I run my code I receive the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 1262, in __init__
    subprocess_call(cmd, logger=None)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/tools.py", line 43, in subprocess_call
    raise IOError(err.decode("utf8"))
OSError: convert: label expected `@/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmpejmzojaq.txt' @ error/annotate.c/GetMultilineTypeMetrics/797.
convert: no images defined `PNG32:/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmp9y2p9b0s.png' @ error/convert.c/ConvertImageCommand/3342.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hypnoticocelot/Downloads/python/tikgenrewrite/tikgen.py", line 366, in <module>
    tikgen()
  File "/Users/hypnoticocelot/Downloads/python/tikgenrewrite/tikgen.py", line 360, in tikgen
    subText = TextClip(subText, font=fontFile, fontsize=75, color=fontColor, stroke_color=strokeColor, stroke_width=3).set_position(("center", 650)).set_duration(mainVideo.duration)
  File "<decorator-gen-84>", line 2, in __init__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 1272, in __init__
    raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:

convert: label expected `@/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmpejmzojaq.txt' @ error/annotate.c/GetMultilineTypeMetrics/797.
convert: no images defined `PNG32:/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmp9y2p9b0s.png' @ error/convert.c/ConvertImageCommand/3342.
.

.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. Check the documentation.

I thought ImageMagick might not have been installed, but running brew install ImageMagick, I'm already on the latest version and fully updated. I'm using a Mac, so I'm not sure if for some reason the path to the ImageMagick binary is somehow incorrect? But I don't see any way to fix this.

  • What version of Imagemagick does MoviePy require? Is it IM 6 or IM 7? – fmw42 Jan 10 '23 at 22:00
  • I'm not sure, I think IM7 is okay though? I last used moviepy around august and v7.1.0-45 worked fine, i recently updated to v7.1.0-57 but still nothing – HypnoticOcelot Jan 10 '23 at 22:23
  • Perhaps you had both IM 6 and IM 7 and it wants IM 6. Check with MoviePy about compatibility. Also be sure your $PATH environment variable has the path to Imagemagick so that MoviePy can find it. Note: I know little about MoviePy – fmw42 Jan 10 '23 at 22:51
  • Are you sure you PNG file exists and you have the correct path to it? – fmw42 Jan 10 '23 at 22:53
  • i don't have any png file as part of my code, i just did `brew install imagemagick` again which updated it, i don't think im6 was ever installed but it was working a couple months back and moviepy hasn't updated since then – HypnoticOcelot Jan 10 '23 at 22:58
  • Are you trying to create a PNG file from some text? Your first error message complains about uff-8 text and then no png file. What was the text you were trying to use? Perhaps some delegate file is missing from your install. What do you get from `magick -version`? – fmw42 Jan 11 '23 at 00:49
  • Version: ImageMagick 7.1.0-57 (Beta) Q16-HDRI x86_64 20701 https://imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC HDRI Modules OpenMP(5.0) Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib Compiler: gcc (4.2) – HypnoticOcelot Jan 11 '23 at 01:05
  • I can add my python script if that'd help – HypnoticOcelot Jan 11 '23 at 01:05
  • Your Imagemagick looks OK. You can provide your Python script. I know that somewhat. But I do not know MoviePy. What do you do with MoviePy -- that is what function are you using it for? – fmw42 Jan 11 '23 at 02:49
  • If you remove the MoviePy part of your script, does the rest run successfully? – fmw42 Jan 11 '23 at 03:14
  • moviepy is the main part of the script, i'm taking two videos and overlaying them on top of each other with `compositevideoclip`. You can learn more about moviepy here: https://zulko.github.io/moviepy/index.html, i'm using version 2.0.0.dev2 - a snippet of my python script is here: https://pastebin.com/krQeF7ZM – HypnoticOcelot Jan 11 '23 at 03:34
  • What font are you trying to use? Perhaps it is missing or not an acceptable font for Imagemagick, which uses fontconfig to process fonts. – fmw42 Jan 11 '23 at 04:09
  • Do you have enough room in your /tmp directory. Perhaps the /tmp directory does not have enough space for the text file you are trying to create. Does MoviePy need any kind of customization for Imagemagick -- specifying directories to use? – fmw42 Jan 11 '23 at 04:13

1 Answers1

0

The solution I found was that my TextClip element wasn’t playing nice when the text in the clip was set to "". An if statement checking if it was empty or not fixed it easily.