Improve testing

This commit is contained in:
henryruhs
2025-05-25 15:45:38 +02:00
parent 441305afe5
commit 84e86ad91e
2 changed files with 22 additions and 24 deletions

View File

@@ -167,8 +167,8 @@ def restore_audio(target_path : str, output_path : str, trim_frame_start : int,
temp_video_format = get_file_format(temp_video_path) temp_video_format = get_file_format(temp_video_path)
temp_video_duration = detect_video_duration(temp_video_path) temp_video_duration = detect_video_duration(temp_video_path)
if temp_video_format in [ 'avi', 'mov' ] and output_audio_encoder == 'flac': if temp_video_format == 'webm':
output_audio_encoder = 'aac' output_audio_encoder = 'libopus'
commands = ffmpeg_builder.chain( commands = ffmpeg_builder.chain(
ffmpeg_builder.set_input(temp_video_path), ffmpeg_builder.set_input(temp_video_path),
@@ -194,8 +194,8 @@ def replace_audio(target_path : str, audio_path : str, output_path : str) -> boo
temp_video_format = get_file_format(temp_video_path) temp_video_format = get_file_format(temp_video_path)
temp_video_duration = detect_video_duration(temp_video_path) temp_video_duration = detect_video_duration(temp_video_path)
if temp_video_format in [ 'avi', 'mov' ] and output_audio_encoder == 'flac': if temp_video_format == 'webm':
output_audio_encoder = 'aac' output_audio_encoder = 'libopus'
commands = ffmpeg_builder.chain( commands = ffmpeg_builder.chain(
ffmpeg_builder.set_input(temp_video_path), ffmpeg_builder.set_input(temp_video_path),

View File

@@ -131,20 +131,19 @@ def test_read_audio_buffer() -> None:
def test_restore_audio() -> None: def test_restore_audio() -> None:
target_paths =\ restore_set =\
[ [
get_test_example_file('target-240p-16khz.avi'), (get_test_example_file('target-240p-16khz.avi'), get_test_output_file('target-240p-16khz.avi')),
get_test_example_file('target-240p-16khz.m4v'), (get_test_example_file('target-240p-16khz.m4v'), get_test_output_file('target-240p-16khz.m4v')),
get_test_example_file('target-240p-16khz.mkv'), (get_test_example_file('target-240p-16khz.mkv'), get_test_output_file('target-240p-16khz.mkv')),
get_test_example_file('target-240p-16khz.mov'), (get_test_example_file('target-240p-16khz.mov'), get_test_output_file('target-240p-16khz.mov')),
get_test_example_file('target-240p-16khz.mp4'), (get_test_example_file('target-240p-16khz.mp4'), get_test_output_file('target-240p-16khz.mp4')),
get_test_example_file('target-240p-48khz.mp4'), (get_test_example_file('target-240p-48khz.mp4'), get_test_output_file('target-240p-48khz.mp4')),
get_test_example_file('target-240p-16khz.webm') (get_test_example_file('target-240p-16khz.webm'), get_test_output_file('target-240p-16khz.webm'))
] ]
output_path = get_test_output_file('test-restore-audio.mp4')
output_audio_encoders = get_available_encoder_set().get('audio') output_audio_encoders = get_available_encoder_set().get('audio')
for target_path in target_paths: for target_path, output_path in restore_set:
create_temp_directory(target_path) create_temp_directory(target_path)
for output_audio_encoder in output_audio_encoders: for output_audio_encoder in output_audio_encoders:
@@ -160,20 +159,19 @@ def test_restore_audio() -> None:
def test_replace_audio() -> None: def test_replace_audio() -> None:
target_paths =\ replace_set =\
[ [
get_test_example_file('target-240p-16khz.avi'), (get_test_example_file('target-240p-16khz.avi'), get_test_output_file('target-240p-16khz.avi')),
get_test_example_file('target-240p-16khz.m4v'), (get_test_example_file('target-240p-16khz.m4v'), get_test_output_file('target-240p-16khz.m4v')),
get_test_example_file('target-240p-16khz.mkv'), (get_test_example_file('target-240p-16khz.mkv'), get_test_output_file('target-240p-16khz.mkv')),
get_test_example_file('target-240p-16khz.mov'), (get_test_example_file('target-240p-16khz.mov'), get_test_output_file('target-240p-16khz.mov')),
get_test_example_file('target-240p-16khz.mp4'), (get_test_example_file('target-240p-16khz.mp4'), get_test_output_file('target-240p-16khz.mp4')),
get_test_example_file('target-240p-48khz.mp4'), (get_test_example_file('target-240p-48khz.mp4'), get_test_output_file('target-240p-48khz.mp4')),
get_test_example_file('target-240p-16khz.webm') (get_test_example_file('target-240p-16khz.webm'), get_test_output_file('target-240p-16khz.webm'))
] ]
output_path = get_test_output_file('test-replace-audio.mp4')
output_audio_encoders = get_available_encoder_set().get('audio') output_audio_encoders = get_available_encoder_set().get('audio')
for target_path in target_paths: for target_path, output_path in replace_set:
create_temp_directory(target_path) create_temp_directory(target_path)
for output_audio_encoder in output_audio_encoders: for output_audio_encoder in output_audio_encoders: