Make Video Utility
Image-to-video conversion utilities.
This module provides lightweight helpers for assembling a sequence of image files into a video file, primarily for visualization of simulation snapshots, plots, or frame-based outputs.
Typical use cases include:
- creating MP4 videos from sequentially saved plot images
- visualizing time evolution of simulation frames
- generating animations for presentations or reports
images_to_video(folder_path, output_file='output_video.mp4', fps=10, ext=('.png', '.jpg', '.jpeg'))
Create a video from an ordered sequence of images in a folder.
Images are collected from the specified directory, filtered by extension, sorted numerically based on the first number appearing in each filename, and encoded into a video file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_path
|
str
|
Path to the directory containing image files. |
required |
output_file
|
str
|
Output video filename, including extension (e.g., |
'output_video.mp4'
|
fps
|
int
|
Frames per second for the generated video. |
10
|
ext
|
tuple[str, ...]
|
Accepted image file extensions. |
('.png', '.jpg', '.jpeg')
|
Returns:
| Type | Description |
|---|---|
str
|
Absolute path to the saved video file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the folder does not exist or contains no valid image files. |
Examples:
>>> images_to_video("frames/", output_file="traj.mp4", fps=15)