Skip to content

Industry leading face manipulation platform

Fix merge edge cases

henryruhs52000114ba3a
diff --git a/facefusion/ffmpeg.py b/facefusion/ffmpeg.py
index 91c8bb3d..d5deb9bb 100644
--- a/facefusion/ffmpeg.py
+++ b/facefusion/ffmpeg.py
@@ -203,6 +203,7 @@ def replace_audio(target_path : str, audio_path : str, output_path : str) -> boo
def merge_video(target_path : str, temp_video_fps : Fps, output_video_resolution : str, output_video_fps : Fps, trim_frame_start : int, trim_frame_end : int) -> bool:
+ output_file_format = get_file_format(target_path)
output_video_encoder = state_manager.get_item('output_video_encoder')
output_video_quality = state_manager.get_item('output_video_quality')
output_video_preset = state_manager.get_item('output_video_preset')
@@ -210,7 +211,10 @@ def merge_video(target_path : str, temp_video_fps : Fps, output_video_resolution
temp_file_path = get_temp_file_path(target_path)
temp_frames_pattern = get_temp_frames_pattern(target_path, '%08d')
- if get_file_format(target_path) == 'webm':
+ if output_file_format == 'mp4' and output_video_encoder == 'rawvideo':
+ output_video_encoder = 'libx264'
+
+ if output_file_format == 'webm':
output_video_encoder = 'libvpx-vp9'
commands = ffmpeg_builder.chain(
diff --git a/tests/test_ffmpeg.py b/tests/test_ffmpeg.py
index 73c12bcf..5d055bb1 100644
--- a/tests/test_ffmpeg.py
+++ b/tests/test_ffmpeg.py
@@ -81,7 +81,7 @@ def test_merge_video() -> None:
merge_set =\
[
(get_test_example_file('target-240p.mp4'), 'libx264'),
- (get_test_example_file('target-240p.mp4'), 'libx265'),
+ (get_test_example_file('target-240p.mp4'), 'rawvideo'),
(get_test_example_file('target-240p.webm'), 'libx264')
]