From 7990896c9e7d2bad9b3962831b57322e7610051a Mon Sep 17 00:00:00 2001 From: henryruhs Date: Tue, 6 Jun 2023 14:10:04 +0200 Subject: [PATCH] Fix sound --- roop/core.py | 4 ++-- roop/utilities.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roop/core.py b/roop/core.py index 92bc897..2bf3ebd 100755 --- a/roop/core.py +++ b/roop/core.py @@ -215,7 +215,7 @@ def start(preview_callback = None) -> None: status('Restoring audio...') else: status('Restoring audio might cause issues as fps are not kept...') - restore_audio(args.target_path) + restore_audio(args.target_path, args.output_path) clean_temp(args.target_path, args.output_path) if is_video(args.target_path): status('Swapping to video succeed!') @@ -256,7 +256,7 @@ def create_test_preview(frame_number): def destroy() -> None: - clean_temp(args.target_path) + clean_temp(args.target_path, args.output_path) quit() diff --git a/roop/utilities.py b/roop/utilities.py index 29789db..acf1632 100644 --- a/roop/utilities.py +++ b/roop/utilities.py @@ -39,8 +39,8 @@ def create_video(target_path: str, fps: int) -> None: run_ffmpeg(['-i', temp_directory_path + os.sep + '%04d.png', '-framerate', str(fps), '-c:v', 'libx264', '-crf', '7', '-pix_fmt', 'yuv420p', '-y', temp_file_path]) -def restore_audio(target_path: str) -> None: - run_ffmpeg(['-i', target_path, '-i', get_temp_file_path(target_path), '-c:v', 'copy', '-map', '0:v:0', 'map', '1:a:0', '-y', get_temp_file_path(target_path)]) +def restore_audio(target_path: str, output_path: str) -> None: + run_ffmpeg(['-i', get_temp_file_path(target_path), '-i', target_path, '-c:v', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-y', output_path]) def get_temp_frames_paths(target_path: str) -> List: @@ -62,7 +62,7 @@ def create_temp(target_path: str) -> None: def clean_temp(target_path: str, output_path: str) -> None: temp_file_path = get_temp_file_path(target_path) - if os.path.isfile(temp_file_path): + if not roop.globals.keep_audio and os.path.isfile(temp_file_path): shutil.move(temp_file_path, output_path) if not roop.globals.keep_frames: shutil.rmtree(get_temp_directory_path(target_path))