Industry leading face manipulation platform
Fix restore audio
henryruhs3c059cfb0e61
diff --git a/facefusion/utilities.py b/facefusion/utilities.pyindex 1e77c1fa..91840697 100644--- a/facefusion/utilities.py+++ b/facefusion/utilities.py@@ -76,17 +76,24 @@ def create_video(target_path : str, fps : float = 30) -> bool:def restore_audio(target_path : str, output_path : str) -> None:+ fps = detect_fps(target_path)trim_frame_start = facefusion.globals.trim_frame_starttrim_frame_end = facefusion.globals.trim_frame_endtemp_output_path = get_temp_output_path(target_path)commands = [ '-hwaccel', 'auto', '-i', temp_output_path, '-i', target_path ]- if trim_frame_start is not None and trim_frame_end is not None:- commands.extend([ '-filter:v', 'select=between(n,' + str(trim_frame_start) + ',' + str(trim_frame_end) + ')' ])- elif trim_frame_start is not None:- commands.extend([ '-filter:v', 'select=gt(n,' + str(trim_frame_start) + ')' ])- elif trim_frame_end is not None:- commands.extend([ '-filter:v', 'select=lt(n,' + str(trim_frame_end) + ')' ])- commands.extend([ '-c:a', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-y', output_path ])+ if trim_frame_start is None and trim_frame_end is None:+ commands.extend([ '-c:a', 'copy' ])+ else:+ if trim_frame_start > 0:+ start_time = trim_frame_start / fps+ commands.extend([ '-ss', str(start_time) ])+ else:+ commands.extend([ '-ss', '0' ])+ if trim_frame_end > 0:+ end_time = trim_frame_end / fps+ commands.extend([ '-to', str(end_time) ])+ commands.extend([ '-c:a', 'aac' ])+ commands.extend([ '-map', '0:v:0', '-map', '1:a:0', '-y', output_path ])done = run_ffmpeg(commands)if not done:move_temp(target_path, output_path)