image-directory-to-video-tool / image_directory_to_video.py
smellslikeml
added image_directory_to_video_tool
87c2878
raw
history blame
798 Bytes
import json
import ffmpeg
from transformers import Tool
class ImageDirectoryToVideoTool(Tool):
name = "image_directory_video_tool"
description = """
This tool creates video
from a directory of images. Inputs
are input_path and output_path.
Output is the output_path.
"""
inputs = ["text", "text"]
outputs = ["text"]
def __call__(
self,
input_path: str,
output_path: str,
framerate: int = 25,
extension: str = "jpg",
):
(
ffmpeg.input(
input_path.rstrip("/") + "/*." + extension.lstrip("."),
pattern_type="glob",
framerate=framerate,
)
.output(output_path)
.run()
)
return output_path