feat(video): 增加4:3 画幅视频合并功能

- 在 VideoAspect 枚举中添加 landscape_2 (4:3) 和 portrait_2 (3:4) 选项
- 更新 combine_clip_videos 函数,支持 4:3 画幅的视频合并
- 修改任务处理流程,使用新的 merger_video 模块进行视频合并
This commit is contained in:
linyq 2025-05-06 22:22:20 +08:00
parent c2711b97c7
commit 2ed627890f
3 changed files with 15 additions and 7 deletions

View File

@ -20,7 +20,9 @@ class VideoConcatMode(str, Enum):
class VideoAspect(str, Enum): class VideoAspect(str, Enum):
landscape = "16:9" landscape = "16:9"
landscape_2 = "4:3"
portrait = "9:16" portrait = "9:16"
portrait_2 = "3:4"
square = "1:1" square = "1:1"
def to_resolution(self): def to_resolution(self):

View File

@ -18,16 +18,22 @@ from loguru import logger
class VideoAspect(Enum): class VideoAspect(Enum):
"""视频宽高比枚举""" """视频宽高比枚举"""
portrait = "portrait" # 竖屏 9:16 landscape = "16:9" # 横屏 16:9
landscape = "landscape" # 横屏 16:9 landscape_2 = "4:3"
square = "square" # 方形 1:1 portrait = "9:16" # 竖屏 9:16
portrait_2 = "3:4"
square = "1:1" # 方形 1:1
def to_resolution(self) -> Tuple[int, int]: def to_resolution(self) -> Tuple[int, int]:
"""根据宽高比返回标准分辨率""" """根据宽高比返回标准分辨率"""
if self == VideoAspect.portrait: if self == VideoAspect.portrait:
return 1080, 1920 # 竖屏 9:16 return 1080, 1920 # 竖屏 9:16
elif self == VideoAspect.portrait_2:
return 720, 1280 # 竖屏 4:3
elif self == VideoAspect.landscape: elif self == VideoAspect.landscape:
return 1920, 1080 # 横屏 16:9 return 1920, 1080 # 横屏 16:9
elif self == VideoAspect.landscape_2:
return 1280, 720 # 横屏 4:3
elif self == VideoAspect.square: elif self == VideoAspect.square:
return 1080, 1080 # 方形 1:1 return 1080, 1080 # 方形 1:1
else: else:

View File

@ -9,7 +9,8 @@ from loguru import logger
from app.config import config from app.config import config
from app.models import const from app.models import const
from app.models.schema import VideoConcatMode, VideoParams, VideoClipParams from app.models.schema import VideoConcatMode, VideoParams, VideoClipParams
from app.services import llm, material, subtitle, video, voice, audio_merger, subtitle_merger, clip_video from app.services import (llm, material, subtitle, video, voice, audio_merger,
subtitle_merger, clip_video, merger_video)
from app.services import state as sm from app.services import state as sm
from app.utils import utils from app.utils import utils
@ -292,11 +293,10 @@ def start_subclip(task_id: str, params: VideoClipParams, subclip_path_videos: di
combined_video_path = path.join(utils.task_dir(task_id), f"merger.mp4") combined_video_path = path.join(utils.task_dir(task_id), f"merger.mp4")
logger.info(f"\n\n## 5. 合并视频: => {combined_video_path}") logger.info(f"\n\n## 5. 合并视频: => {combined_video_path}")
video.combine_clip_videos( merger_video.combine_clip_videos(
combined_video_path=combined_video_path, output_video_path=combined_video_path,
video_paths=subclip_videos, video_paths=subclip_videos,
video_ost_list=video_ost, video_ost_list=video_ost,
list_script=list_script,
video_aspect=params.video_aspect, video_aspect=params.video_aspect,
threads=params.n_threads # 多线程 threads=params.n_threads # 多线程
) )