mirror of
https://github.com/artegoser/image-pluser-webui.git
synced 2024-12-22 16:53:49 +03:00
feat: video to images
This commit is contained in:
parent
7bf970cf1b
commit
eb26452ad6
3 changed files with 9 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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'):
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Add table
Reference in a new issue