From 6d9d3730328fbdaa9efb930f680f4246fb662df4 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 23 Jan 2025 14:28:51 +0800 Subject: [PATCH] =?UTF-8?q?only=20if=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/ffmpeg.py | 16 ++++++++++++++++ util/api.py | 3 +++ 2 files changed, 19 insertions(+) diff --git a/biz/ffmpeg.py b/biz/ffmpeg.py index 927637c..d0868ea 100644 --- a/biz/ffmpeg.py +++ b/biz/ffmpeg.py @@ -20,6 +20,11 @@ def parse_ffmpeg_task(task_info, template_info): if not source: logger.warning("no video found for part: " + str(part)) 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.annexb = True 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) +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): for task in ffmpeg_task.analyze_input_render_tasks(): start_ffmpeg_task(task) diff --git a/util/api.py b/util/api.py index 59206dd..80ad92d 100644 --- a/util/api.py +++ b/util/api.py @@ -101,6 +101,9 @@ def get_template_info(template_id): _luts = template_info.get('luts', '') if _luts: _template['luts'] = _luts.split(",") + _only_if = template_info.get('onlyIf', '') + if _only_if: + _template['only_if'] = _only_if return _template # outer template definition