From 04ce423811c33e1e471559802ec58fc2f77d4757 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 29 May 2025 10:01:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A3=81=E5=88=87=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=8E=B7=E5=8F=96=EF=BC=8C=E9=81=BF=E5=85=8D=E5=90=8C?= =?UTF-8?q?=E6=9C=BA=E4=BD=8D=E5=A4=9A=E7=B4=A0=E6=9D=90=E5=87=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/ffmpeg.py | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/biz/ffmpeg.py b/biz/ffmpeg.py index b8d22e0..5b60412 100644 --- a/biz/ffmpeg.py +++ b/biz/ffmpeg.py @@ -24,7 +24,7 @@ def parse_ffmpeg_task(task_info, template_info): task_params = json.loads(task_params_str) task_params_orig = json.loads(task_params_str) for part in template_info.get("video_parts"): - source = parse_video(part.get('source'), task_params, template_info) + source, ext_data = parse_video(part.get('source'), task_params, template_info) if not source: logger.warning("no video found for part: " + str(part)) continue @@ -36,7 +36,7 @@ def parse_ffmpeg_task(task_info, template_info): sub_ffmpeg_task = FfmpegTask(source) sub_ffmpeg_task.resolution = template_info.get("video_size", "") sub_ffmpeg_task.annexb = True - sub_ffmpeg_task.ext_data = find_placeholder_params(part.get('source'), task_params_orig) or {} + sub_ffmpeg_task.ext_data = ext_data or {} sub_ffmpeg_task.frame_rate = template_info.get("frame_rate", 25) sub_ffmpeg_task.center_cut = part.get("crop_mode", None) for effect in part.get('effects', []): @@ -55,8 +55,9 @@ def parse_ffmpeg_task(task_info, template_info): task.center_cut = template_info.get("crop_mode", None) task.frame_rate = template_info.get("frame_rate", 25) if overall.get('source', ''): - source = parse_video(overall.get('source'), task_params, template_info) + source, ext_data = parse_video(overall.get('source'), task_params, template_info) task.add_inputs(source) + task.ext_data = ext_data or {} for effect in overall.get('effects', []): task.add_effect(effect) for lut in overall.get('filters', []): @@ -68,37 +69,24 @@ def parse_ffmpeg_task(task_info, template_info): return task -def find_placeholder_params(source, task_params): - if source.startswith('PLACEHOLDER_'): - placeholder_id = source.replace('PLACEHOLDER_', '') - new_sources = task_params.get(placeholder_id, []) - if type(new_sources) is list: - if len(new_sources) == 0: - logger.debug("no video found for placeholder: " + placeholder_id) - return {} - else: - return new_sources[0] - return {} - - def parse_video(source, task_params, template_info): - print(source) if source.startswith('PLACEHOLDER_'): placeholder_id = source.replace('PLACEHOLDER_', '') new_sources = task_params.get(placeholder_id, []) + _pick_source = {} if type(new_sources) is list: if len(new_sources) == 0: logger.debug("no video found for placeholder: " + placeholder_id) - return None + return None, _pick_source else: _pick_source = new_sources.pop(0) new_sources = _pick_source.get("url") if new_sources.startswith("http"): _, source_name = os.path.split(new_sources) oss.download_from_oss(new_sources, source_name) - return source_name - return new_sources - return os.path.join(template_info.get("local_path"), source) + return source_name, _pick_source + return new_sources, _pick_source + return os.path.join(template_info.get("local_path"), source), None def check_placeholder_exist(placeholder_id, task_params):