Make a video from images using python3

Gabriel Kasser
1 min readMar 12, 2023

Easy, efficient and quick way:

pip install olympict
from olympict import ImagePipeline

(
ImagePipeline.load_folder("./examples")
.to_video(lambda _: "./output.mkv", 24) # save video with 24 FPS
.wait_for_completion()
)

And voilà ! You got your video 😁

But, what if my images need to be resized ?

Okay, you can choose a new size easily:

from olympict import ImagePipeline

(
ImagePipeline.load_folder("./examples")
.resize((640, 480)) # add an image resize (width, height)
.to_video(lambda _: "./output.mkv", 24)
.wait_for_completion()
)

Here is your 640x480 video 😀

Okay, but my images aspect ratio was not kept 😧

Well, here is how to manage this:

from olympict import ImagePipeline

(
ImagePipeline.load_folder("./examples")
.resize((640, 480), pad_color=(0, 0, 0)) # pad with black to keep ratio
.to_video(lambda _: "./output.mkv", 24)
.wait_for_completion()
)

There you go 😉

It’s close to perfect, how can i add some small edits ?

You can use any opencv-python image operation on each image like this:

from olympict import ImagePipeline

(
ImagePipeline.load_folder("./examples")
.resize((640, 480), pad_color=(0, 0, 0))
.task_img(lambda x: x[::-1, :, :]) # flip video upside down
.to_video(lambda _: "./output.mkv", 24)
.wait_for_completion()
)

Open to other questions 😄

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response