2017-09-19 5 views
0

J'utilise ce code par exemple en cas de test: https://matplotlib.org/examples/animation/moviewriter.htmlPuis-je enregistrer une animation matplotlib au format webm?

Dans ce code, ils utilisent ffmpeg pour écrire l'animation matplotlib à un fichier vidéo .mp4. Est-il possible d'écrire dans un format .webm? Mais je ne suis pas sûr de savoir comment y arriver.

+1

Vous pouvez utiliser ffmpeg pour convertir le fichier voir https://thethemefoundry.com/blog/convert-mp4-to-webm/ –

+0

Bien sûr, mais je veux savoir si je peux utiliser matplotlib directement à la sortie en format webm. –

Répondre

2

Assurez-vous que vous avez ffmpegcompiled avec libvpx (exécuter ffmpeg sans arguments et voir s'il y a une --enable-libvpx dans la sortie).

FFMpegWriter = manimation.writers['ffmpeg'] 
writer = FFMpegWriter(fps=15, codec='libvpx-vp9') # or libvpx-vp8 

[...] 

with writer.saving(fig, "writer_test.webm", 100): 
    [...] 
+0

Merci, cela a fonctionné parfaitement! –