moviepy报错之 .This error can be due to the fact that ImageMagick is not installed on your computer(亲测)
說明:
今天安裝moviepy這個模塊一直用不了,結(jié)果突然測試說是缺少ImageMagick。
剛MoviePy入門跑第一個代碼,就一直弄不了,后來發(fā)現(xiàn)還是環(huán)境沒有配置好,下午就遇見了,一直沒有解決,暫時先放一邊了,到了晚上十點,突然又想搞這個問題了,最終搞到現(xiàn)在(凌晨2:37分,心累呀),現(xiàn)在把這個問題的全部解決思路寫下來,希望遇見這個問題的小伙伴少走彎路吧。
一、報錯內(nèi)容
OSError: MoviePy Error: creation of None failed because of the following error:
[WinError 2] 系統(tǒng)找不到指定的文件。.
.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
1
2
3
4
5
6
二、最終的解決方法:
1、安裝 ImageMagick
剛開始一直無法解決,最終想到這個ImageMagick我感覺什么時間用過,想著就想到我之前最PDF轉(zhuǎn)圖片學(xué)習(xí)遇見過一次,這裝了好久,發(fā)現(xiàn)用之前公司電腦上裝的軟件和家里的筆記本不一樣了,不知道為什么,但是公司的雖然臺式機,但是是64位呀,搞得我有點懵。
這個我是下載好的,我的是Windows10系統(tǒng),64位的筆記本,目前這個我電腦安裝就能成功了。
ghostscript文件是我測試pdf轉(zhuǎn)圖片測試的軟件,如果只是解決這個問題,可以忽略這個軟件即可。
https://www.lanzous.com/b00ta2vzi
密碼:3z4e
1
2
安裝時ImageMagick注意有倆點:
安裝過程注意勾選Install development headers and libraries for C and C++ 。
安裝后設(shè)置MAGICK_HOME環(huán)境變量,值為imagemagick的安裝路徑,并將安裝路徑加入path。
2、安裝成功之后,修改moviepy模塊下的config_defaults.py文件
具體位置,可以參考的python安裝位置:
比如我的python安裝位置為:D:\python_study_tools\python36,對應(yīng)的修改文件位置:
D:\python_study_tools\python36\Lib\site-packages\moviepy\config_defaults.py
1
修改修改的就是IMAGEMAGICK_BINARY的值,改為剛剛你安裝ImageMagick的目錄下。
比如我的安裝目錄是D:\python_study_tools\ImageMagick-7.0.9-Q16:
FFMPEG_BINARY = os.getenv('FFMPEG_BINARY', 'ffmpeg-imageio')
# IMAGEMAGICK_BINARY = os.getenv('IMAGEMAGICK_BINARY', 'auto-detect')
# 修改為剛剛ImageMagic的安裝路徑
IMAGEMAGICK_BINARY = r"D:\python_study_tools\ImageMagick-7.0.9-Q16\magick.exe" ?
1
2
3
4
三、測試代碼:
至此就可以測試代碼了。
我這里測試的moviepy官方代碼,我只是修改了視頻文件:
# Import everything needed to edit video clips
from moviepy.editor import *
# Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60
# 加載myHolidays.mp4并選擇子片段00:00:50-00:00:60
clip = VideoFileClip("000result.mp4").subclip(50,60)
# Reduce the audio volume (volume x 0.8)
# 降低音量(音量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')
# Say that you want it to appear 10s at the center of the screen
# 假設(shè)您希望它在屏幕中央顯示10秒
txt_clip = txt_clip.set_pos('center').set_duration(10)
# Overlay the text clip on the first video clip
# Overlay the text clip on the first video clip
video = CompositeVideoClip([clip, txt_clip])
# Write the result to a file (many options available !)
# 將結(jié)果寫入文件(許多選項可用!)
# video.write_videofile("myHolidays_edited.webm")
video.write_videofile("myHolidays_edited.mp4")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
這里已經(jīng)成功了。
好了,問題解決,睡覺睡覺,困死了。
此時已經(jīng)凌晨三點了,衰。。。
————————————————
版權(quán)聲明:本文為CSDN博主「奮斗吧-皮卡丘」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_42081389/article/details/104322629
總結(jié)
以上是生活随笔為你收集整理的moviepy报错之 .This error can be due to the fact that ImageMagick is not installed on your computer(亲测)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。