diff --git a/processing/bulk.py b/processing/bulk.py index fe7c230..bc8ab79 100644 --- a/processing/bulk.py +++ b/processing/bulk.py @@ -18,7 +18,8 @@ def images_to_video(directory, fps, img_ext, img_name_format, video_name, video_ def video_to_images(video_path, img_ext): + images_pattern = generate_name( - extension=img_ext, name=video_path, subfolder=os.path.join("images", get_date_text())) + extension=img_ext, name=f"%d", subfolder=os.path.join("images", get_date_text())) ffmpeg.input(video_path).output(images_pattern).run() diff --git a/processing/utils.py b/processing/utils.py index f201d26..dd26018 100644 --- a/processing/utils.py +++ b/processing/utils.py @@ -4,12 +4,12 @@ import datetime def generate_name(name=False, subfolder="stacked", extension="png", format='%Y-%m-%d_%H-%M-%S'): - os.makedirs(os.path.join("./output", subfolder), exist_ok=True) + os.makedirs(os.path.join(".", "output", subfolder), exist_ok=True) if name is False or name == "": name = get_date_text(format) - return os.path.join("./output", subfolder, f"{name}.{extension}") + return os.path.join(".", "output", subfolder, f"{name}.{extension}") def get_date_text(format='%Y-%m-%d_%H-%M-%S'): diff --git a/tabs/Video to images/app.py b/tabs/Video to images/app.py index d11d6e8..3e6ce4f 100644 --- a/tabs/Video to images/app.py +++ b/tabs/Video to images/app.py @@ -1,12 +1,16 @@ import gradio as gr +from processing.bulk import video_to_images with gr.Blocks() as app: gr.Markdown( - "Convert video to images. # **WIP, not working**") + "Convert video to images.") with gr.Row(): with gr.Column(): + video = gr.Video(label="Video") + with gr.Column(): format = gr.Radio( choices=["png", "jpg"], value="png", label="Format of image") submit = gr.Button("Submit") + submit.click(fn=video_to_images, inputs=[video, format])