mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-27 12:30:55 +02:00
67 lines
3.3 KiB
Python
67 lines
3.3 KiB
Python
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
from facefusion import ffmpeg, ffmpeg_builder, process_manager
|
|
from facefusion.download import conditional_download
|
|
from facefusion.jobs.job_manager import clear_jobs, init_jobs
|
|
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
|
|
|
|
|
|
@pytest.fixture(scope = 'module', autouse = True)
|
|
def before_all() -> None:
|
|
process_manager.start()
|
|
conditional_download(get_test_examples_directory(),
|
|
[
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.mp3',
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
|
|
])
|
|
|
|
ffmpeg.run_ffmpeg(
|
|
ffmpeg_builder.chain(
|
|
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
|
|
[
|
|
'-vframes',
|
|
'1'
|
|
],
|
|
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
|
|
)
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope = 'function', autouse = True)
|
|
def before_each() -> None:
|
|
clear_jobs(get_test_jobs_directory())
|
|
init_jobs(get_test_jobs_directory())
|
|
prepare_test_output_directory()
|
|
|
|
|
|
def test_sync_lip_to_image() -> None:
|
|
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'audio-to-image:video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image.mp4') ]
|
|
|
|
assert subprocess.run(commands).returncode == 0
|
|
assert is_test_output_file('test_sync_lip_to_image.mp4') is True
|
|
|
|
|
|
def test_sync_lip_to_image_as_frames() -> None:
|
|
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'audio-to-image:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image_as_frames') ]
|
|
|
|
assert subprocess.run(commands).returncode == 0
|
|
assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_image_as_frames')) is True
|
|
|
|
|
|
def test_sync_lip_to_video() -> None:
|
|
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video.mp4'), '--trim-frame-end', '1' ]
|
|
|
|
assert subprocess.run(commands).returncode == 0
|
|
assert is_test_output_file('test_sync_lip_to_video.mp4') is True
|
|
|
|
|
|
def test_sync_lip_to_video_as_frames() -> None:
|
|
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video_as_frames'), '--trim-frame-end', '1' ]
|
|
|
|
assert subprocess.run(commands).returncode == 0
|
|
assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_video_as_frames')) is True
|