92 lines
2.5 KiB
Python
92 lines
2.5 KiB
Python
#!/usr/bin/python
|
|
from itertools import product
|
|
|
|
options = {
|
|
"x264enc": {
|
|
"bitrate" : ["10000", "20000", "5000"],
|
|
"speed-preset" : ["ultrafast", "fast", "medium"],
|
|
"tune": ["zerolatency"],
|
|
"slices-threads": ["true", "false"],
|
|
"b-adapt": ["true", "false"],
|
|
"rc-lookahead": ["40", "0"],
|
|
"ref": ["3", "0"]
|
|
|
|
},
|
|
"nvh264enc" : {
|
|
"bitrate" : ["10000", "20000", "5000"],
|
|
"preset" : ["4", "5", "1"],
|
|
"rc-lookahead" : ["0"],
|
|
"rc-mode" : ["2", "0", "5"],
|
|
"zerolatency": ["true", "false"],
|
|
|
|
},
|
|
"nvv4l2h264enc": {
|
|
"bitrate" : ["10000000", "20000000", "5000000"],
|
|
"profile": ["0", "1", "2"],
|
|
"preset-id": ["1", "2", "3"],
|
|
"control-id": ["1", "2"],
|
|
"tuning-info-id": ["4", "2"]
|
|
}
|
|
}
|
|
|
|
videos = [""]
|
|
|
|
testsource = "videotestsrc pattern=smpte"
|
|
videosrc = ["filesrc location=", "! qtdemux ! h264parse ! avdec_h264"]
|
|
|
|
psnr_check = {
|
|
"x264enc": "-pixel_format yuv420p -color_range pc",
|
|
"nvh264enc": "-pixel_format nv12 -color_range tv",
|
|
"nvv4l2h264enc": "-pixel_format yuv420p -color_range tv"
|
|
}
|
|
|
|
formats = {
|
|
"x264enc" : "I420",
|
|
"nvh264enc" : "NV12",
|
|
"nvv4l2h264enc": "I420"
|
|
}
|
|
|
|
profiles = ["baseline", "main"]
|
|
|
|
def makeVideoSrc(idx):
|
|
return videosrc[0] + videos[idx] + videosrc[1]
|
|
|
|
def generateEncoderStrings():
|
|
global options
|
|
result = dict()
|
|
for encoder, value in options.items():
|
|
result[encoder] = generate_combinations(value)
|
|
return result
|
|
|
|
def generate_combinations(config_dict):
|
|
"""
|
|
Generate all combinations of values from a configuration dictionary.
|
|
|
|
Args:
|
|
config_dict (dict): Dictionary with parameter names as keys and lists of values as values
|
|
|
|
Returns:
|
|
list: List of strings containing all parameter combinations
|
|
"""
|
|
combinations = []
|
|
|
|
# Get the keys and values in consistent order
|
|
keys = list(config_dict.keys())
|
|
value_lists = [config_dict[key] for key in keys]
|
|
|
|
# Generate all combinations using itertools.product
|
|
for combo in product(*value_lists):
|
|
# Create a list of key=value strings
|
|
param_strings = []
|
|
for key, value in zip(keys, combo):
|
|
param_strings.append(f"{key}={value}")
|
|
|
|
# Join all parameter strings with space separator
|
|
combinations.append(" ".join(param_strings))
|
|
|
|
return combinations
|
|
|
|
def generateRecordString(options, ):
|
|
pass
|
|
|
|
print(len(generateEncoderStrings()[""])) |