Windows 용 애니메이션 GIF를 며칠 동안 내보내려고했습니다.matplotlib을 사용하여 애니메이션 GIF 내보내기
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot([], [], 'ro', animated=True)
def init():
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1, 1)
return ln,
def update(frame):
xdata.append(frame)
ydata.append(np.sin(frame))
ln.set_data(xdata, ydata)
return ln,
ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
init_func=init, blit=True)
ani.save("test.gif")
plt.show()
그리고 오류 : 나는 MP4로 출력 파일 형식을 전환하면
>>> python .\anim_test.py
Traceback (most recent call last):
File ".\anim_test.py", line 22, in <module>
ani.save("test.gif")
File "C:\Users\ishma\Anaconda2\lib\site-packages\matplotlib\animation.py", line 1063, in save
writer.grab_frame(**savefig_kwargs)
File "C:\Users\ishma\Anaconda2\lib\site-packages\matplotlib\animation.py", line 336, in grab_frame
'with --verbose-debug.'.format(e, out, err))
IOError: Error saving animation to file (cause: [Errno 22] Invalid argument) Stdout: StdError: . It may help to re-run
with --verbose-debug.
PS C:\Users\ishma\Dropbox (SteinLab)\spectra\MassSpecPlot> python .\anim_test.py --verbose-debug
$HOME=C:\Users\ishma
matplotlib data path C:\Users\ishma\Anaconda2\lib\site-packages\matplotlib\mpl-data
*****************************************************************
You have the following UNSUPPORTED LaTeX preamble customizations:
Please do not ask for support with these customizations active.
*****************************************************************
loaded rc file C:\Users\ishma\Anaconda2\lib\site-packages\matplotlib\mpl-data\matplotlibrc
matplotlib version 2.0.2
verbose.level debug
interactive is False
platform is win32
loaded modules: <dictionary-keyiterator object at 0x0000000003EA0048>
CACHEDIR=C:\Users\ishma\.matplotlib
Using fontManager instance from C:\Users\ishma\.matplotlib\fontList.cache
backend Qt5Agg version 5.6
Animation.save using <class 'matplotlib.animation.FFMpegWriter'>
frame size in pixels is 640 x 480
MovieWriter.run: running command: ffmpeg -f rawvideo -vcodec rawvideo -s 640x480 -pix_fmt rgba -r 5.0 -i pipe: -vcodec h
264 -pix_fmt yuv420p -y test.gif
MovieWriter.grab_frame: Grabbing frame.
findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=400:stretch=normal:size=10.0 to DejaVu Sans (u'
C:\\Users\\ishma\\Anaconda2\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\DejaVuSans.ttf') with score of 0.0000
00
MovieWriter.grab_frame: Grabbing frame.
MovieWriter -- Error running proc:
None
None
MovieWriter -- Command stdout:
None
MovieWriter -- Command stderr:
None
Traceback (most recent call last):
File ".\anim_test.py", line 22, in <module>
ani.save("test.gif")
File "C:\Users\ishma\Anaconda2\lib\site-packages\matplotlib\animation.py", line 1063, in save
writer.grab_frame(**savefig_kwargs)
File "C:\Users\ishma\Anaconda2\lib\site-packages\matplotlib\animation.py", line 336, in grab_frame
'with --verbose-debug.'.format(e, out, err))
IOError: Error saving animation to file (cause: [Errno 22] Invalid argument) Stdout: None StdError: None. It may help to
re-run with --verbose-debug.
는, 코드가 작동
여기에 기본 코드입니다. 비디오 파일을 생성하는 오류가있는 사람들로부터 많은 스레드를 읽은 후에는 다른 작성자 (FFMpegWriter, ImageMagickWriter, AVConvWriter 및 FileWriters도 포함)의 모든 조합을 시도한 것처럼 관련 프로그램이 내 PATH에 있는지, 설정이 변경되었는지 확인했습니다. matplotlibrc에서 여러 대의 컴퓨터를 사용해 보았습니다. 나는 혼란 스럽다.
나는이 정확한 오류를 참조하는 하나의 스레드 발견했습니다 https://stackoverflow.com/questions/46562938/oserror-errno-22-invalid-argument-error-saving-animation-to-file
을하지만 거기에 코멘트에 조언 다음은 내 문제를 해결하지 않았습니다.
아이디어가 있으십니까? 어떤 도움을 주셔서 감사합니다.
전화
의 경로를 설정합니다. 그럴까요? 그래도 ImageMagick 디렉토리에 ffmpeg.exe가 있습니다. – ishmandoo
ImageMagick 7을 사용하는 경우 convert가 magick으로 이름이 변경되었습니다. 그럼 magick.exe가 있습니까? – fmw42
@ fmw42'ImageMagick-7.0.3-Q16'이 있는데'convert.exe'가 있습니다. 또한 magick.exe도 있지만이 경우에는 유용하지 않습니다. 이름 바꾸기에 대한 귀하의 주장에 대한 근원이 있습니까? 그렇지 않으면 나는 그것을 신뢰하지 않을 것이다. – ImportanceOfBeingErnest