remove output_path argument

This commit is contained in:
harisreedhar
2025-11-14 21:20:06 +05:30
committed by henryruhs
parent 49b6acfecf
commit 820134698b
5 changed files with 15 additions and 14 deletions
+6 -6
View File
@@ -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')
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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
+2 -1
View File
@@ -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: