From 820134698b04a87c4e211d770a0742dc78c7d335 Mon Sep 17 00:00:00 2001 From: harisreedhar Date: Fri, 14 Nov 2025 21:20:06 +0530 Subject: [PATCH] remove output_path argument --- facefusion/ffmpeg.py | 12 ++++++------ facefusion/temp_helper.py | 6 +++--- facefusion/workflows/image_to_image.py | 4 ++-- tests/test_ffmpeg.py | 4 ++-- tests/test_temp_helper.py | 3 ++- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/facefusion/ffmpeg.py b/facefusion/ffmpeg.py index dc94ac3a..7da0e6bb 100644 --- a/facefusion/ffmpeg.py +++ b/facefusion/ffmpeg.py @@ -125,8 +125,8 @@ def extract_frames(target_path : str, temp_video_resolution : Resolution, temp_v return process.returncode == 0 -def copy_image(target_path : str, output_path : str, temp_image_resolution : Resolution) -> bool: - temp_image_path = get_temp_file_path(target_path, output_path) +def copy_image(target_path : str, temp_image_resolution : Resolution) -> bool: + temp_image_path = get_temp_file_path(target_path) commands = ffmpeg_builder.chain( ffmpeg_builder.set_input(target_path), ffmpeg_builder.set_media_resolution(pack_resolution(temp_image_resolution)), @@ -138,7 +138,7 @@ def copy_image(target_path : str, output_path : str, temp_image_resolution : Res def finalize_image(target_path : str, output_path : str, output_image_resolution : Resolution) -> bool: output_image_quality = state_manager.get_item('output_image_quality') - temp_image_path = get_temp_file_path(target_path, output_path) + temp_image_path = get_temp_file_path(target_path) commands = ffmpeg_builder.chain( ffmpeg_builder.set_input(temp_image_path), ffmpeg_builder.set_media_resolution(pack_resolution(output_image_resolution)), @@ -170,7 +170,7 @@ def restore_audio(target_path : str, output_path : str, trim_frame_start : int, output_audio_quality = state_manager.get_item('output_audio_quality') output_audio_volume = state_manager.get_item('output_audio_volume') target_video_fps = detect_video_fps(target_path) - temp_video_path = get_temp_file_path(target_path, output_path) + temp_video_path = get_temp_file_path(target_path) temp_video_format = cast(VideoFormat, get_file_format(output_path)) temp_video_duration = detect_video_duration(temp_video_path) @@ -195,7 +195,7 @@ def replace_audio(target_path : str, audio_path : str, output_path : str) -> boo output_audio_encoder = state_manager.get_item('output_audio_encoder') output_audio_quality = state_manager.get_item('output_audio_quality') output_audio_volume = state_manager.get_item('output_audio_volume') - temp_video_path = get_temp_file_path(target_path, output_path) + temp_video_path = get_temp_file_path(target_path) temp_video_format = cast(VideoFormat, get_file_format(output_path)) temp_video_duration = detect_video_duration(temp_video_path) @@ -220,7 +220,7 @@ def merge_video(target_path : str, temp_video_fps : Fps, output_video_resolution output_video_quality = state_manager.get_item('output_video_quality') output_video_preset = state_manager.get_item('output_video_preset') merge_frame_total = predict_video_frame_total(target_path, output_video_fps, trim_frame_start, trim_frame_end) - temp_video_path = get_temp_file_path(target_path, output_path) + temp_video_path = get_temp_file_path(target_path) temp_video_format = cast(VideoFormat, get_file_format(output_path)) temp_frames_pattern = get_temp_frames_pattern(target_path, '%08d') diff --git a/facefusion/temp_helper.py b/facefusion/temp_helper.py index e7deb423..370c8555 100644 --- a/facefusion/temp_helper.py +++ b/facefusion/temp_helper.py @@ -5,14 +5,14 @@ from facefusion import state_manager from facefusion.filesystem import create_directory, get_file_extension, get_file_name, move_file, remove_directory, resolve_file_pattern -def get_temp_file_path(file_path : str, move_path : str) -> str: +def get_temp_file_path(file_path : str) -> str: temp_directory_path = get_temp_directory_path(file_path) - temp_file_extension = get_file_extension(move_path) + temp_file_extension = get_file_extension(state_manager.get_item('output_path')) return os.path.join(temp_directory_path, 'temp' + temp_file_extension) def move_temp_file(file_path : str, move_path : str) -> bool: - temp_file_path = get_temp_file_path(file_path, move_path) + temp_file_path = get_temp_file_path(file_path) return move_file(temp_file_path, move_path) diff --git a/facefusion/workflows/image_to_image.py b/facefusion/workflows/image_to_image.py index cf82ddb3..da36e1bc 100644 --- a/facefusion/workflows/image_to_image.py +++ b/facefusion/workflows/image_to_image.py @@ -47,7 +47,7 @@ def prepare_image() -> ErrorCode: temp_image_resolution = restrict_image_resolution(state_manager.get_item('target_path'), output_image_resolution) logger.info(translator.get('copying_image').format(resolution = pack_resolution(temp_image_resolution)), __name__) - if ffmpeg.copy_image(state_manager.get_item('target_path'), state_manager.get_item('output_path'), temp_image_resolution): + if ffmpeg.copy_image(state_manager.get_item('target_path'), temp_image_resolution): logger.debug(translator.get('copying_image_succeeded'), __name__) else: logger.error(translator.get('copying_image_failed'), __name__) @@ -57,7 +57,7 @@ def prepare_image() -> ErrorCode: def process_image() -> ErrorCode: - temp_image_path = get_temp_file_path(state_manager.get_item('target_path'), state_manager.get_item('output_path')) + temp_image_path = get_temp_file_path(state_manager.get_item('target_path')) reference_vision_frame = read_static_image(temp_image_path) source_vision_frames = read_static_images(state_manager.get_item('source_paths')) source_audio_frame = create_empty_audio_frame() diff --git a/tests/test_ffmpeg.py b/tests/test_ffmpeg.py index d73cc893..19dede96 100644 --- a/tests/test_ffmpeg.py +++ b/tests/test_ffmpeg.py @@ -154,7 +154,7 @@ def test_restore_audio() -> None: for output_audio_encoder in output_audio_encoders: state_manager.init_item('output_audio_encoder', output_audio_encoder) - copy_file(target_path, get_temp_file_path(target_path, output_path)) + copy_file(target_path, get_temp_file_path(target_path)) assert restore_audio(target_path, output_path, 0, 270) is True @@ -181,7 +181,7 @@ def test_replace_audio() -> None: for output_audio_encoder in output_audio_encoders: state_manager.init_item('output_audio_encoder', output_audio_encoder) - copy_file(target_path, get_temp_file_path(target_path, output_path)) + copy_file(target_path, get_temp_file_path(target_path)) assert replace_audio(target_path, get_test_example_file('source.mp3'), output_path) is True assert replace_audio(target_path, get_test_example_file('source.wav'), output_path) is True diff --git a/tests/test_temp_helper.py b/tests/test_temp_helper.py index e6cace7a..e9f53242 100644 --- a/tests/test_temp_helper.py +++ b/tests/test_temp_helper.py @@ -20,8 +20,9 @@ def before_all() -> None: def test_get_temp_file_path() -> None: + state_manager.init_item('output_path', 'temp.mp4') temp_directory = tempfile.gettempdir() - assert get_temp_file_path(get_test_example_file('target-240p.mp4'), get_test_example_file('target-240p.mp4')) == os.path.join(temp_directory, 'facefusion', 'target-240p', 'temp.mp4') + assert get_temp_file_path(get_test_example_file('target-240p.mp4')) == os.path.join(temp_directory, 'facefusion', 'target-240p', 'temp.mp4') def test_get_temp_directory_path() -> None: