Respect the trim frame args on UI launch

This commit is contained in:
henryruhs 2023-08-22 10:09:27 +02:00
parent d8d607cb23
commit 09c2fb2f46
2 changed files with 5 additions and 6 deletions

View File

@ -21,21 +21,20 @@ def render() -> None:
with gradio.Box():
trim_frame_start_slider_args : Dict[str, Any] = {
'label': wording.get('trim_frame_start_slider_label'),
'value': facefusion.globals.trim_frame_start,
'step': 1,
'visible': False
}
trim_frame_end_slider_args : Dict[str, Any] = {
'label': wording.get('trim_frame_end_slider_label'),
'value': facefusion.globals.trim_frame_end,
'step': 1,
'visible': False
}
if is_video(facefusion.globals.target_path):
video_frame_total = get_video_frame_total(facefusion.globals.target_path)
trim_frame_start_slider_args['value'] = facefusion.globals.trim_frame_start or 0
trim_frame_start_slider_args['maximum'] = video_frame_total
trim_frame_start_slider_args['visible'] = True
trim_frame_end_slider_args['value'] = video_frame_total
trim_frame_end_slider_args['value'] = facefusion.globals.trim_frame_end or video_frame_total
trim_frame_end_slider_args['maximum'] = video_frame_total
trim_frame_end_slider_args['visible'] = True
with gradio.Row():

View File

@ -71,11 +71,11 @@ def test_extract_frames_with_trim_start() -> None:
def test_extract_frames_with_trim_start_and_trim_end() -> None:
facefusion.globals.trim_frame_start = 224
facefusion.globals.trim_frame_end = 324
facefusion.globals.trim_frame_start = 124
facefusion.globals.trim_frame_end = 224
data_provider =\
[
('.assets/examples/target-240p-25fps.mp4', 55),
('.assets/examples/target-240p-25fps.mp4', 120),
('.assets/examples/target-240p-30fps.mp4', 100),
('.assets/examples/target-240p-60fps.mp4', 50)
]