I am trying to make typing text video in python using moviepy but imagemagick is not detected in both IDE pycharm (community) and anaconda (spyder), the moviepy is working good tried with other code in with text is not involved, the code is below:
from moviepy.editor import TextClip, concatenate_videoclips
import math
import os
os.environ['IMAGEIO_ffmpeg_EXE'] = 'C:/Program Files/ImageMagick-7.1.0-Q16-HDRI/ffmpeg.exe'
def append_text_as_frames(txtClip, text, duration, fps):
nframes = int(math.ceil(duration * fps))
txtClipList = []
for i in range(nframes):
txt = TextClip(text[:int(i/nframes*len(text))], color='white', fontsize=70, font='Amiri-Bold').set_duration(1/fps)
txt = txt.set_pos(('center', 'center'))
txtClipList.append(txt)
return txtClipList
filename = "input_text.txt"
with open(filename, "r", encoding="utf8") as f:
text = f.read()
duration = len(text) / 10 # assuming a typing speed of 10 characters per second
fps = 30
txtClipList = append_text_as_frames(TextClip('', color='white', fontsize=70, font='Amiri-Bold'), text, duration, fps)
final_clip = concatenate_videoclips(txtClipList)
final_clip.write_videofile("my_video.mp4", fps=fps)
OSError: MoviePy Error: creation of None failed because of the following error:
convert.exe: label expected
@C:\Users\faisal\AppData\Local\Temp\tmpmj_kvwnl.txt' @ error/annotate.c/GetMultilineTypeMetrics/797. convert.exe: no images defined
PNG32:C:\Users\faisal\AppData\Local\Temp\tmpq7w_xi84.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 in file conf.py, or that the path you specified is incorrect