From 820f601b32a944218e7036444391c90ff0402a5b Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Thu, 6 Aug 2026 16:50:34 +0800 Subject: [PATCH] 1 --- video-gen-api/app/tasks/api_upscale_tasks.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/video-gen-api/app/tasks/api_upscale_tasks.py b/video-gen-api/app/tasks/api_upscale_tasks.py index 5cf7dca9..957f682f 100644 --- a/video-gen-api/app/tasks/api_upscale_tasks.py +++ b/video-gen-api/app/tasks/api_upscale_tasks.py @@ -7,6 +7,7 @@ from __future__ import annotations import logging from datetime import datetime, timezone +import os from typing import Any from app.config import settings @@ -82,7 +83,7 @@ def api_upscale_execute_local_simple(self, upscale_task_id: str) -> dict[str, An """简化版本地超分执行(API v3 专用)。""" from app.models.base import async_session from app.models.video_upscale_task import VideoUpscaleTask - from app.services.video_upscale.local_ffmpeg_service import run_local_ffmpeg_upscale + from app.services.video_upscale.local_ffmpeg_service import execute_local_ffmpeg_crop from sqlalchemy import select async def _execute(): @@ -105,18 +106,25 @@ def api_upscale_execute_local_simple(self, upscale_task_id: str) -> dict[str, An await db.commit() try: + # 构建输出路径 + date_dir = _now_str() + final_local_path = f"./storage/generate/api/videos/{date_dir}/{upscale.api_generation_task_id or 'unknown'}.mp4" + # 执行本地 FFmpeg 超分 - output_path = await run_local_ffmpeg_upscale(upscale) + output_path = await execute_local_ffmpeg_crop( + source_path=upscale.source_local_path, + final_path=final_local_path, + target_width=int(upscale.target_width or 0), + target_height=int(upscale.target_height or 0), + ) # 计算相对 URL 路径 - # output_path 是绝对路径,需要转换为 /generate/api/videos/... 格式 - date_dir = _now_str() url_path = f"/generate/api/videos/{date_dir}/{upscale.api_generation_task_id}.mp4" # 更新成功状态 upscale.status = "completed" upscale.stage = "upscale_completed" - upscale.final_local_path = f"./storage/generate/api/videos/{_now_str()}/{upscale.api_generation_task_id or "unknown"}.mp4" + upscale.final_local_path = final_local_path upscale.final_resource_url = url_path # 相对 URL upscale.completed_at = _now()