Fix sound

This commit is contained in:
henryruhs 2023-06-06 14:10:04 +02:00
parent 09ea59f66f
commit 7990896c9e
2 changed files with 5 additions and 5 deletions

View File

@ -215,7 +215,7 @@ def start(preview_callback = None) -> None:
status('Restoring audio...') status('Restoring audio...')
else: else:
status('Restoring audio might cause issues as fps are not kept...') 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) clean_temp(args.target_path, args.output_path)
if is_video(args.target_path): if is_video(args.target_path):
status('Swapping to video succeed!') status('Swapping to video succeed!')
@ -256,7 +256,7 @@ def create_test_preview(frame_number):
def destroy() -> None: def destroy() -> None:
clean_temp(args.target_path) clean_temp(args.target_path, args.output_path)
quit() quit()

View File

@ -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]) 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: def restore_audio(target_path: str, output_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)]) 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: 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: def clean_temp(target_path: str, output_path: str) -> None:
temp_file_path = get_temp_file_path(target_path) 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) shutil.move(temp_file_path, output_path)
if not roop.globals.keep_frames: if not roop.globals.keep_frames:
shutil.rmtree(get_temp_directory_path(target_path)) shutil.rmtree(get_temp_directory_path(target_path))