From 04319fb3c6de64b64603fccf97f7b342e228ed54 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Fri, 23 May 2025 13:09:54 +0200 Subject: [PATCH] More edge case testing --- facefusion/ffmpeg.py | 2 +- tests/test_ffmpeg.py | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/facefusion/ffmpeg.py b/facefusion/ffmpeg.py index d5deb9b..07f950a 100644 --- a/facefusion/ffmpeg.py +++ b/facefusion/ffmpeg.py @@ -211,7 +211,7 @@ 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 output_file_format == 'mp4' and output_video_encoder == 'rawvideo': + if output_file_format in [ 'm4v', 'mkv', 'mp4' ] and output_video_encoder == 'rawvideo': output_video_encoder = 'libx264' if output_file_format == 'webm': diff --git a/tests/test_ffmpeg.py b/tests/test_ffmpeg.py index a1e5968..1256536 100644 --- a/tests/test_ffmpeg.py +++ b/tests/test_ffmpeg.py @@ -22,6 +22,8 @@ def before_all() -> None: ]) subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.mp3'), get_test_example_file('source.wav') ]) subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), get_test_example_file('target-240p.avi') ]) + subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), get_test_example_file('target-240p.m4v') ]) + subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), get_test_example_file('target-240p.mkv') ]) subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), get_test_example_file('target-240p.mov') ]) subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), get_test_example_file('target-240p.webm') ]) subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=25', get_test_example_file('target-240p-25fps.mp4') ]) @@ -81,18 +83,19 @@ def test_extract_frames() -> None: def test_merge_video() -> None: merge_set =\ [ - (get_test_example_file('target-240p.avi'), 'libx264'), - (get_test_example_file('target-240p.mov'), 'libx264'), - (get_test_example_file('target-240p.mp4'), 'libx264'), - (get_test_example_file('target-240p.mp4'), 'rawvideo'), - (get_test_example_file('target-240p.webm'), 'libx264'), - (get_test_example_file('target-240p.webm'), 'rawvideo') + get_test_example_file('target-240p.avi'), + get_test_example_file('target-240p.m4v'), + get_test_example_file('target-240p.mkv'), + get_test_example_file('target-240p.mp4'), + get_test_example_file('target-240p.mov'), + get_test_example_file('target-240p.webm') ] - for target_path, output_video_encoder in merge_set: - state_manager.init_item('output_video_encoder', output_video_encoder) - create_temp_directory(target_path) - extract_frames(target_path, '452x240', 25.0, 0, 1) + for target_path in merge_set: + for output_video_encoder in get_available_encoder_set().get('video'): + state_manager.init_item('output_video_encoder', output_video_encoder) + create_temp_directory(target_path) + extract_frames(target_path, '452x240', 25.0, 0, 1) assert merge_video(target_path, 25.0, '452x240', 25.0, 0, 1) is True