#Python 🐍 – 2 lines to create a gif from a video 🎦 using moviepy

Buy Me A Coffee

Hi !

Today I’ll share another cool sample using moviepy.

This one is easy: create a gif from a video file. And in this scenario, I added some extra features

  • Use the Video frames from seconds 1 to 5
  • Resize the output to 50% of the original file

The code is super simple

from moviepy.editor import VideoFileClip, clips_array, vfx
clip = (VideoFileClip("cat1.mp4")
clip.write_gif("cats can be friendly.gif")

Super, easy. It and the output is a 2MB gif file.

cats can be friendly animated gif

Source video, the full version is here.

Happy coding!


El Bruno

More posts in my blog ElBruno.com.

¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: