First set for extract_frames()
This commit is contained in:
parent
2de53c57fb
commit
ca206f1c99
@ -6,7 +6,7 @@ from facefusion.utilities import conditional_download
|
||||
|
||||
|
||||
@pytest.fixture(scope = 'module', autouse = True)
|
||||
def setup() -> None:
|
||||
def before_all() -> None:
|
||||
conditional_download('.assets/examples',
|
||||
[
|
||||
'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.jpg',
|
||||
@ -18,6 +18,7 @@ def setup() -> None:
|
||||
def test_image_to_image() -> None:
|
||||
commands = [ 'python', 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.jpg', '-o', '.assets/examples' ]
|
||||
run = subprocess.run(commands, stdout = subprocess.PIPE)
|
||||
|
||||
assert run.returncode == 0
|
||||
assert wording.get('processing_image_succeed') in run.stdout.decode()
|
||||
|
||||
@ -25,5 +26,6 @@ def test_image_to_image() -> None:
|
||||
def test_image_to_video() -> None:
|
||||
commands = [ 'python', 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.mp4', '-o', '.assets/examples', '--trim-frame-end', '10' ]
|
||||
run = subprocess.run(commands, stdout = subprocess.PIPE)
|
||||
|
||||
assert run.returncode == 0
|
||||
assert wording.get('processing_video_succeed') in run.stdout.decode()
|
||||
|
@ -1,21 +1,52 @@
|
||||
import glob
|
||||
import subprocess
|
||||
import pytest
|
||||
|
||||
from facefusion.utilities import conditional_download, detect_fps
|
||||
import facefusion.globals
|
||||
from facefusion.utilities import conditional_download, detect_fps, extract_frames, create_temp, get_temp_directory_path, clear_temp
|
||||
|
||||
|
||||
@pytest.fixture(scope = 'module', autouse = True)
|
||||
def setup() -> None:
|
||||
def before_all() -> None:
|
||||
facefusion.globals.temp_frame_quality = 100
|
||||
facefusion.globals.trim_frame_start = None
|
||||
facefusion.globals.trim_frame_end = None
|
||||
facefusion.globals.temp_frame_format = 'png'
|
||||
conditional_download('.assets/examples',
|
||||
[
|
||||
'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-1080p.mp4'
|
||||
'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4'
|
||||
])
|
||||
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-1080p.mp4', '-vf', 'fps=25', '.assets/examples/target-1080p-25fps.mp4' ])
|
||||
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-1080p.mp4', '-vf', 'fps=30', '.assets/examples/target-1080p-30fps.mp4' ])
|
||||
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-1080p.mp4', '-vf', 'fps=60', '.assets/examples/target-1080p-60fps.mp4' ])
|
||||
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=25', '.assets/examples/target-240p-25fps.mp4' ])
|
||||
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=30', '.assets/examples/target-240p-30fps.mp4' ])
|
||||
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=60', '.assets/examples/target-240p-60fps.mp4' ])
|
||||
|
||||
|
||||
@pytest.fixture(scope = 'function', autouse = True)
|
||||
def before_each() -> None:
|
||||
facefusion.globals.trim_frame_start = None
|
||||
facefusion.globals.trim_frame_end = None
|
||||
facefusion.globals.temp_frame_quality = 90
|
||||
facefusion.globals.temp_frame_format = 'jpg'
|
||||
|
||||
|
||||
def test_detect_fps() -> None:
|
||||
assert detect_fps('.assets/examples/target-1080p-25fps.mp4') == 25.0
|
||||
assert detect_fps('.assets/examples/target-1080p-30fps.mp4') == 30.0
|
||||
assert detect_fps('.assets/examples/target-1080p-60fps.mp4') == 60.0
|
||||
assert detect_fps('.assets/examples/target-240p-25fps.mp4') == 25.0
|
||||
assert detect_fps('.assets/examples/target-240p-30fps.mp4') == 30.0
|
||||
assert detect_fps('.assets/examples/target-240p-60fps.mp4') == 60.0
|
||||
|
||||
|
||||
def test_extract_frames() -> None:
|
||||
target_paths =\
|
||||
[
|
||||
'.assets/examples/target-240p-25fps.mp4',
|
||||
'.assets/examples/target-240p-30fps.mp4',
|
||||
'.assets/examples/target-240p-60fps.mp4'
|
||||
]
|
||||
for target_path in target_paths:
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
create_temp(target_path)
|
||||
|
||||
assert extract_frames(target_path, 30) is True
|
||||
assert len(glob.glob1(temp_directory_path, '*.jpg')) == 324
|
||||
|
||||
clear_temp(target_path)
|
||||
|
Loading…
Reference in New Issue
Block a user