#Python 🐍 – Let’s stack and edit some videos 🎦 using moviepy

Buy Me A Coffee

Hi !

Today I’ll share another cool Python library: moviepy.

And, as usual let’s share the code, the best way to explain part of this library capabilities

from moviepy.editor import VideoFileClip, clips_array, vfx
clip11 = VideoFileClip("cat1.mp4").margin(10)
clip21 = VideoFileClip("cat2.mp4").margin(10)
clip12 = clip11.fx( vfx.mirror_x)
clip22 = clip21.fx( vfx.mirror_y)
final_clip = clips_array([[clip11, clip21],
[clip12, clip22]])
final_clip.resize(width=480).write_videofile("stacked_vid.mp4")

Super, easy. It start with 2 cats videos, create 2 new videos with mirroring effects from the source videos, and create a final video with the 4 videos stacked. Let’s take a look at the final video

stacked_vid_5sec (2)

And, of course, this is video editing, so the process may take some time.

moviepy stack process on console

Check the official moviepy installation guide.

Bonus, source videos are here

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.

More info in https://beacons.ai/elbruno



¿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:

Advertisement

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: