forked from CrypticSignal/video-quality-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharguments_validator.py
More file actions
35 lines (26 loc) · 1.17 KB
/
arguments_validator.py
File metadata and controls
35 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
from utils import is_list
class ArgumentsValidator:
def validate(self, args):
validation_results = []
validation_errors = []
result = True
validation_results.append(self.__validate_original_video_exists(
args.original_video_path))
validation_results.append(
self.__validate_crf_and_preset_count(
args.crf_value, args.preset))
for validation_tuple in validation_results:
if not validation_tuple[0]:
result = False
validation_errors.append(validation_tuple[1])
return result, validation_errors
def __validate_original_video_exists(self, video_path):
return (os.path.exists(video_path), f'Unable to find {video_path}')
def __validate_crf_and_preset_count(self, crf_values, presets):
result = True
if is_list(crf_values) and len(crf_values) > 1 and is_list(presets) \
and len(presets) > 1:
result = False
return (result, 'More than one CRF value AND more than one preset '
'specified. No suitable mode found.')