jhj0517
commited on
Commit
•
b5da8a7
1
Parent(s):
e6eff1c
Add video validation function
Browse files- tests/test_config.py +25 -3
tests/test_config.py
CHANGED
@@ -13,9 +13,9 @@ from modules.utils.paths import *
|
|
13 |
|
14 |
TEST_IMAGE_URL = "https://github.com/microsoft/onnxjs-demo/raw/master/src/assets/EmotionSampleImages/sad_baby.jpg"
|
15 |
TEST_VIDEO_URL = "https://github.com/jhj0517/sample-medias/raw/master/vids/human-face/expression01_short.mp4"
|
16 |
-
TEST_IMAGE_PATH = os.path.join(PROJECT_ROOT_DIR, "tests", "test.png")
|
17 |
-
TEST_VIDEO_PATH = os.path.join(PROJECT_ROOT_DIR, "tests", "test_expression.mp4")
|
18 |
-
TEST_EXPRESSION_OUTPUT_PATH = os.path.join(PROJECT_ROOT_DIR, "tests", "edited_expression.png")
|
19 |
TEST_EXPRESSION_AAA = 100
|
20 |
|
21 |
|
@@ -71,6 +71,28 @@ def are_videos_different(video1_path: str, video2_path: str):
|
|
71 |
return False
|
72 |
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
def has_sound(video_path: str):
|
75 |
try:
|
76 |
video = VideoFileClip(video_path)
|
|
|
13 |
|
14 |
TEST_IMAGE_URL = "https://github.com/microsoft/onnxjs-demo/raw/master/src/assets/EmotionSampleImages/sad_baby.jpg"
|
15 |
TEST_VIDEO_URL = "https://github.com/jhj0517/sample-medias/raw/master/vids/human-face/expression01_short.mp4"
|
16 |
+
TEST_IMAGE_PATH = os.path.normpath(os.path.join(PROJECT_ROOT_DIR, "tests", "test.png"))
|
17 |
+
TEST_VIDEO_PATH = os.path.normpath(os.path.join(PROJECT_ROOT_DIR, "tests", "test_expression.mp4"))
|
18 |
+
TEST_EXPRESSION_OUTPUT_PATH = os.path.normpath(os.path.join(PROJECT_ROOT_DIR, "tests", "edited_expression.png"))
|
19 |
TEST_EXPRESSION_AAA = 100
|
20 |
|
21 |
|
|
|
71 |
return False
|
72 |
|
73 |
|
74 |
+
def validate_video(video_path):
|
75 |
+
cap = cv2.VideoCapture(video_path)
|
76 |
+
if not cap.isOpened():
|
77 |
+
print("Could not open video file.")
|
78 |
+
return False
|
79 |
+
|
80 |
+
frame_count = 0
|
81 |
+
while True:
|
82 |
+
ret, frame = cap.read()
|
83 |
+
if not ret:
|
84 |
+
break
|
85 |
+
frame_count += 1
|
86 |
+
|
87 |
+
cap.release()
|
88 |
+
|
89 |
+
if frame_count == 0:
|
90 |
+
print("No frames found in video file.")
|
91 |
+
return False
|
92 |
+
|
93 |
+
return True
|
94 |
+
|
95 |
+
|
96 |
def has_sound(video_path: str):
|
97 |
try:
|
98 |
video = VideoFileClip(video_path)
|