only if 逻辑

This commit is contained in:
2025-01-23 14:28:51 +08:00
parent 549ee8320a
commit 6d9d373032
2 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,11 @@ def parse_ffmpeg_task(task_info, template_info):
if not source: if not source:
logger.warning("no video found for part: " + str(part)) logger.warning("no video found for part: " + str(part))
continue continue
only_if = part.get('only_if', '')
if only_if:
if not check_placeholder_exist(only_if, task_params):
logger.info("because only_if exist, placeholder: %s not exist, skip part: %s", only_if, part)
continue
sub_ffmpeg_task = FfmpegTask(source) sub_ffmpeg_task = FfmpegTask(source)
sub_ffmpeg_task.annexb = True sub_ffmpeg_task.annexb = True
sub_ffmpeg_task.frame_rate = template_info.get("frame_rate", 25) sub_ffmpeg_task.frame_rate = template_info.get("frame_rate", 25)
@ -66,6 +71,17 @@ def parse_video(source, task_params, template_info):
return os.path.join(template_info.get("local_path"), source) return os.path.join(template_info.get("local_path"), source)
def check_placeholder_exist(placeholder_id, task_params):
if placeholder_id in task_params:
new_sources = task_params.get(placeholder_id, [])
if type(new_sources) is list:
if len(new_sources) == 0:
return False
else:
return True
return True
return False
def start_ffmpeg_task(ffmpeg_task): def start_ffmpeg_task(ffmpeg_task):
for task in ffmpeg_task.analyze_input_render_tasks(): for task in ffmpeg_task.analyze_input_render_tasks():
start_ffmpeg_task(task) start_ffmpeg_task(task)

View File

@ -101,6 +101,9 @@ def get_template_info(template_id):
_luts = template_info.get('luts', '') _luts = template_info.get('luts', '')
if _luts: if _luts:
_template['luts'] = _luts.split(",") _template['luts'] = _luts.split(",")
_only_if = template_info.get('onlyIf', '')
if _only_if:
_template['only_if'] = _only_if
return _template return _template
# outer template definition # outer template definition