Make a video from images using python3
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 😄