允许跳过下载,并发下载,env和版本更新

This commit is contained in:
2025-07-18 12:32:15 +08:00
parent 13a10b9812
commit 4b080771f6
6 changed files with 39 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
import json
import os.path
import time
from concurrent.futures import ThreadPoolExecutor
from opentelemetry.trace import Status, StatusCode
@@ -21,8 +22,18 @@ def parse_ffmpeg_task(task_info, template_info):
# 中间片段
task_params_str = task_info.get("taskParams", "{}")
span.set_attribute("task_params", task_params_str)
task_params = json.loads(task_params_str)
task_params: dict = json.loads(task_params_str)
task_params_orig = json.loads(task_params_str)
with tracer.start_as_current_span("parse_ffmpeg_task.download_all") as sub_span:
with ThreadPoolExecutor(max_workers=8) as executor:
param_list: list[dict]
for param_list in task_params.values():
for param in param_list:
url = param.get("url")
if url.startswith("http"):
_, fn = os.path.split(url)
executor.submit(oss.download_from_oss, url, fn, True)
executor.shutdown(wait=True)
for part in template_info.get("video_parts"):
source, ext_data = parse_video(part.get('source'), task_params, template_info)
if not source:
@@ -54,10 +65,10 @@ def parse_ffmpeg_task(task_info, template_info):
overall = template_info.get("overall_template")
task.center_cut = template_info.get("crop_mode", None)
task.frame_rate = template_info.get("frame_rate", 25)
if overall.get('source', ''):
source, ext_data = parse_video(overall.get('source'), task_params, template_info)
task.add_inputs(source)
task.ext_data = ext_data or {}
# if overall.get('source', ''):
# 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', []):
@@ -83,7 +94,7 @@ def parse_video(source, task_params, template_info):
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)
oss.download_from_oss(new_sources, source_name, True)
return source_name, _pick_source
return new_sources, _pick_source
return os.path.join(template_info.get("local_path"), source), None