Enregistrer une animation matplolib en format .mp4
Résolu
maxime.f
-
maxime.f -
maxime.f -
Bonjour à tous !
J'ai pour projet de réaliser diverses animations et je souhaiterais les enregistrer en format .mp4
Voici donc un code test pour m’entraîner à enregistrer
L'animation marche très bien sans la partie #enregistrement, mais quand je l’exécute avec il y a le message d'erreur suivant que je n'arrive vraiment pas à comprendre :
"
Traceback (most recent call last):
File "C:\Users\Victor SECHAUD\Desktop\test_enregistrement.py", line 33, in <module>
myAnimation.save("test1", writer = writer, dpi=DPI)
File "c:\users\victor sechaud\appdata\local\programs\python\python37-32\lib\site-packages\matplotlib\animation.py", line 1174, in save
writer.grab_frame(**savefig_kwargs)
File "c:\users\victor sechaud\appdata\local\programs\python\python37-32\lib\site-packages\matplotlib\animation.py", line 383, in grab_frame
'DEBUG.'.format(e, out, err))
OSError: Error saving animation to file (cause: [Errno 22] Invalid argument) Stdout: b'' StdError: b''. It may help to re-run with logging level set to DEBUG."
Donc si quelqu'un arrivait à m'expliquer la cause de ce message et comment corriger cela je vous en serais très reconnaissant !
PS : le format .mp4 n'est pas obligatoire, juste un format que je puisse lire avec mon ordinateur.
Merci d'avance !
J'ai pour projet de réaliser diverses animations et je souhaiterais les enregistrer en format .mp4
Voici donc un code test pour m’entraîner à enregistrer
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation plt.rcParams['animation.ffmpeg_path'] = r'C:\ffmpeg\bin\ffmpeg.exe' TWOPI = 2*np.pi fig, ax = plt.subplots() t = np.arange(0.0, TWOPI, 0.001) s = np.sin(t) l = plt.plot(t, s) ax = plt.axis([0,TWOPI,-1,1]) redDot, = plt.plot([0], [np.sin(0)], 'ro') def animate(i): redDot.set_data(i, np.sin(i)) return redDot, myAnimation = animation.FuncAnimation(fig, animate, frames=np.arange(0.0, TWOPI, 0.1), \ interval=10, blit=True, repeat=False) #plt.show() DPI=90 writer = animation.FFMpegWriter(fps=30, bitrate=5000) myAnimation.save("test1", writer = writer, dpi=DPI)
L'animation marche très bien sans la partie #enregistrement, mais quand je l’exécute avec il y a le message d'erreur suivant que je n'arrive vraiment pas à comprendre :
"
Traceback (most recent call last):
File "C:\Users\Victor SECHAUD\Desktop\test_enregistrement.py", line 33, in <module>
myAnimation.save("test1", writer = writer, dpi=DPI)
File "c:\users\victor sechaud\appdata\local\programs\python\python37-32\lib\site-packages\matplotlib\animation.py", line 1174, in save
writer.grab_frame(**savefig_kwargs)
File "c:\users\victor sechaud\appdata\local\programs\python\python37-32\lib\site-packages\matplotlib\animation.py", line 383, in grab_frame
'DEBUG.'.format(e, out, err))
OSError: Error saving animation to file (cause: [Errno 22] Invalid argument) Stdout: b'' StdError: b''. It may help to re-run with logging level set to DEBUG."
Donc si quelqu'un arrivait à m'expliquer la cause de ce message et comment corriger cela je vous en serais très reconnaissant !
PS : le format .mp4 n'est pas obligatoire, juste un format que je puisse lire avec mon ordinateur.
Merci d'avance !
Configuration: Windows / Chrome 80.0.3987.122
A voir également:
- Matplotlib animation save mp4
- Save as pdf office 2007 - Télécharger - Bureautique
- Singe mp4 - Télécharger - TV & Vidéo
- Codec mp4 - Télécharger - Conversion & Codecs
- Extraire audio mp4 - Guide
- Save tube - Télécharger - Téléchargement & Transfert
Je vais aller tester la ligne que vous m'avez donner pour essayer de mieux comprendre ce qu'il s'est passé.