refactor video file create and save

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-01-15 13:03:40 -05:00
parent 0ac2e3c12e
commit 5a59054eec
21 changed files with 166 additions and 265 deletions
+3 -17
View File
@@ -15,6 +15,7 @@ from scripts.xyz_grid_draw import draw_xyz_grid # pylint: disable=no-name-in-mod
from scripts.xyz_grid_shared import apply_field, apply_task_args, apply_setting, apply_prompt, apply_order, apply_sampler, apply_hr_sampler_name, confirm_samplers, apply_checkpoint, apply_refiner, apply_unet, apply_dict, apply_clip_skip, apply_vae, list_lora, apply_lora, apply_lora_strength, apply_te, apply_styles, apply_upscaler, apply_context, apply_detailer, apply_override, apply_processing, apply_options, apply_seed, format_value_add_label, format_value, format_value_join_list, do_nothing, format_nothing # pylint: disable=no-name-in-module, unused-import
from modules import shared, errors, scripts, images, processing
from modules.ui_components import ToolButton
from modules.ui_sections import create_video_inputs
import modules.ui_symbols as symbols
@@ -64,23 +65,8 @@ class Script(scripts.Script):
create_video = gr.Checkbox(label='Create video', value=False, elem_id=self.elem_id("xyz_create_video"), container=False)
with gr.Row(visible=False) as ui_video:
def video_type_change(video_type):
return [
gr.update(visible=video_type != 'None'),
gr.update(visible=video_type == 'GIF' or video_type == 'PNG'),
gr.update(visible=video_type == 'MP4'),
gr.update(visible=video_type == 'MP4'),
]
with gr.Column():
video_type = gr.Dropdown(label='Video type', choices=['None', 'GIF', 'PNG', 'MP4'], value='None')
with gr.Column():
video_duration = gr.Slider(label='Duration', minimum=0.25, maximum=300, step=0.25, value=2, visible=False)
video_loop = gr.Checkbox(label='Loop', value=True, visible=False, elem_id="control_video_loop")
video_pad = gr.Slider(label='Pad frames', minimum=0, maximum=24, step=1, value=1, visible=False)
video_interpolate = gr.Slider(label='Interpolate frames', minimum=0, maximum=24, step=1, value=0, visible=False)
video_type.change(fn=video_type_change, inputs=[video_type], outputs=[video_duration, video_loop, video_pad, video_interpolate])
create_video.change(fn=lambda x: gr.update(visible=x), inputs=[create_video], outputs=[ui_video])
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs()
create_video.change(fn=lambda x: gr.update(visible=x), inputs=[create_video], outputs=[ui_video])
with gr.Row():
margin_size = gr.Slider(label="Grid margins", minimum=0, maximum=500, value=0, step=2, elem_id=self.elem_id("margin_size"))