Skip to content

Industry leading face manipulation platform

First set for extract_frames()

henryruhsca206f1c99ae
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 138177ed..8a48a028 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -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()
diff --git a/tests/test_utilities.py b/tests/test_utilities.py
index 251d57dd..8acba7dd 100644
--- a/tests/test_utilities.py
+++ b/tests/test_utilities.py
@@ -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' ])
+
+
[email protected](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)