Simplify code and reduce to 25fps by default
This commit is contained in:
parent
09c2fb2f46
commit
0c34dd846c
@ -150,16 +150,12 @@ def process_image() -> None:
|
|||||||
def process_video() -> None:
|
def process_video() -> None:
|
||||||
if predict_video(facefusion.globals.target_path):
|
if predict_video(facefusion.globals.target_path):
|
||||||
return
|
return
|
||||||
|
fps = detect_fps(facefusion.globals.target_path) if facefusion.globals.keep_fps else 25.0
|
||||||
update_status(wording.get('creating_temp'))
|
update_status(wording.get('creating_temp'))
|
||||||
create_temp(facefusion.globals.target_path)
|
create_temp(facefusion.globals.target_path)
|
||||||
# extract frames
|
# extract frames
|
||||||
if facefusion.globals.keep_fps:
|
update_status(wording.get('extracting_frames_fps').format(fps = fps))
|
||||||
fps = detect_fps(facefusion.globals.target_path)
|
extract_frames(facefusion.globals.target_path, fps)
|
||||||
update_status(wording.get('extracting_frames_fps').format(fps = fps))
|
|
||||||
extract_frames(facefusion.globals.target_path, fps)
|
|
||||||
else:
|
|
||||||
update_status(wording.get('extracting_frames_fps').format(fps = 30))
|
|
||||||
extract_frames(facefusion.globals.target_path)
|
|
||||||
# process frame
|
# process frame
|
||||||
temp_frame_paths = get_temp_frame_paths(facefusion.globals.target_path)
|
temp_frame_paths = get_temp_frame_paths(facefusion.globals.target_path)
|
||||||
if temp_frame_paths:
|
if temp_frame_paths:
|
||||||
@ -171,15 +167,9 @@ def process_video() -> None:
|
|||||||
update_status(wording.get('temp_frames_not_found'))
|
update_status(wording.get('temp_frames_not_found'))
|
||||||
return
|
return
|
||||||
# create video
|
# create video
|
||||||
if facefusion.globals.keep_fps:
|
update_status(wording.get('creating_video_fps').format(fps = fps))
|
||||||
fps = detect_fps(facefusion.globals.target_path)
|
if not create_video(facefusion.globals.target_path, fps):
|
||||||
update_status(wording.get('creating_video_fps').format(fps = fps))
|
update_status(wording.get('creating_video_failed'))
|
||||||
if not create_video(facefusion.globals.target_path, fps):
|
|
||||||
update_status(wording.get('creating_video_failed'))
|
|
||||||
else:
|
|
||||||
update_status(wording.get('creating_video_fps').format(fps = 30))
|
|
||||||
if not create_video(facefusion.globals.target_path):
|
|
||||||
update_status(wording.get('creating_video_failed'))
|
|
||||||
# handle audio
|
# handle audio
|
||||||
if facefusion.globals.skip_audio:
|
if facefusion.globals.skip_audio:
|
||||||
move_temp(facefusion.globals.target_path, facefusion.globals.output_path)
|
move_temp(facefusion.globals.target_path, facefusion.globals.output_path)
|
||||||
|
@ -44,7 +44,7 @@ def detect_fps(target_path : str) -> Optional[float]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def extract_frames(target_path : str, fps : float = 30) -> bool:
|
def extract_frames(target_path : str, fps : float) -> bool:
|
||||||
temp_directory_path = get_temp_directory_path(target_path)
|
temp_directory_path = get_temp_directory_path(target_path)
|
||||||
temp_frame_quality = round(31 - (facefusion.globals.temp_frame_quality * 0.31))
|
temp_frame_quality = round(31 - (facefusion.globals.temp_frame_quality * 0.31))
|
||||||
trim_frame_start = facefusion.globals.trim_frame_start
|
trim_frame_start = facefusion.globals.trim_frame_start
|
||||||
@ -62,7 +62,7 @@ def extract_frames(target_path : str, fps : float = 30) -> bool:
|
|||||||
return run_ffmpeg(commands)
|
return run_ffmpeg(commands)
|
||||||
|
|
||||||
|
|
||||||
def create_video(target_path : str, fps : float = 30) -> bool:
|
def create_video(target_path : str, fps : float) -> bool:
|
||||||
temp_output_path = get_temp_output_path(target_path)
|
temp_output_path = get_temp_output_path(target_path)
|
||||||
temp_directory_path = get_temp_directory_path(target_path)
|
temp_directory_path = get_temp_directory_path(target_path)
|
||||||
output_video_quality = round(51 - (facefusion.globals.output_video_quality * 0.5))
|
output_video_quality = round(51 - (facefusion.globals.output_video_quality * 0.5))
|
||||||
|
@ -46,7 +46,7 @@ def test_extract_frames() -> None:
|
|||||||
temp_directory_path = get_temp_directory_path(target_path)
|
temp_directory_path = get_temp_directory_path(target_path)
|
||||||
create_temp(target_path)
|
create_temp(target_path)
|
||||||
|
|
||||||
assert extract_frames(target_path, 30) is True
|
assert extract_frames(target_path, 30.0) is True
|
||||||
assert len(glob.glob1(temp_directory_path, '*.jpg')) == 324
|
assert len(glob.glob1(temp_directory_path, '*.jpg')) == 324
|
||||||
|
|
||||||
clear_temp(target_path)
|
clear_temp(target_path)
|
||||||
@ -64,7 +64,7 @@ def test_extract_frames_with_trim_start() -> None:
|
|||||||
temp_directory_path = get_temp_directory_path(target_path)
|
temp_directory_path = get_temp_directory_path(target_path)
|
||||||
create_temp(target_path)
|
create_temp(target_path)
|
||||||
|
|
||||||
assert extract_frames(target_path, 30) is True
|
assert extract_frames(target_path, 30.0) is True
|
||||||
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
||||||
|
|
||||||
clear_temp(target_path)
|
clear_temp(target_path)
|
||||||
@ -83,7 +83,7 @@ def test_extract_frames_with_trim_start_and_trim_end() -> None:
|
|||||||
temp_directory_path = get_temp_directory_path(target_path)
|
temp_directory_path = get_temp_directory_path(target_path)
|
||||||
create_temp(target_path)
|
create_temp(target_path)
|
||||||
|
|
||||||
assert extract_frames(target_path, 30) is True
|
assert extract_frames(target_path, 30.0) is True
|
||||||
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
||||||
|
|
||||||
clear_temp(target_path)
|
clear_temp(target_path)
|
||||||
@ -101,7 +101,7 @@ def test_extract_frames_with_trim_end() -> None:
|
|||||||
temp_directory_path = get_temp_directory_path(target_path)
|
temp_directory_path = get_temp_directory_path(target_path)
|
||||||
create_temp(target_path)
|
create_temp(target_path)
|
||||||
|
|
||||||
assert extract_frames(target_path, 30) is True
|
assert extract_frames(target_path, 30.0) is True
|
||||||
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
||||||
|
|
||||||
clear_temp(target_path)
|
clear_temp(target_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user