模板渲染逻辑调整

This commit is contained in:
lmk
2026-08-28 13:38:40 +08:00
parent 486c4a2ff7
commit 68a5f45173
3 changed files with 5 additions and 5 deletions
-3
View File
@@ -29,9 +29,6 @@ func (c *template) CreateTemplate(ctx context.Context, req *dto.CreateTemplateTa
if len(req.VideoURLs) < 1 {
return nil, fmt.Errorf("至少需要1个视频")
}
if len(req.Templates) < 1 {
return nil, fmt.Errorf("至少需要1个HTML模板")
}
taskID, taskErr := service.Template.CreateAsyncTask(ctx, req.VideoURLs, req.AudioURL, req.Templates, req.Subtitles, req.SubtitleStyle, req.CallbackURL)
if taskErr != nil {
+1 -1
View File
@@ -19,7 +19,7 @@ type CreateTemplateTaskReq struct {
g.Meta `path:"/template" method:"post" tags:"模板视频" summary:"创建模板视频任务(异步)" dc:"使用HTML模板+数据创建营销视频,支持多段模板不同时间区间,返回taskId"`
VideoURLs []string `json:"video_urls" v:"required#视频URL列表不能为空" dc:"背景视频URL列表"`
AudioURL string `json:"audio_url" dc:"背景音频URL(可选)"`
Templates []HtmlTemplate `json:"templates" v:"required#模板列表不能为空" dc:"HTML模板列表,每段可指定时间范围和填充数据"`
Templates []HtmlTemplate `json:"templates" dc:"HTML模板列表,每段可指定时间范围和填充数据。传空数组=跳过模板逻辑,仅拼接视频+音频+字幕"`
Subtitles []SubtitleSegment `json:"subtitles" dc:"字幕时间线列表(可选)"`
SubtitleStyle *SubtitleStyle `json:"subtitle_style" dc:"字幕样式配置(可选)"`
CallbackURL string `json:"callback_url" dc:"任务完成后的回调地址(可选)"`
+4 -1
View File
@@ -29,8 +29,11 @@ func (s *templateService) CreateAsyncTask(ctx context.Context, videoURLs []strin
if len(videoURLs) < 1 {
return "", fmt.Errorf("至少需要1个视频")
}
// templates 为空:跳过模板解析与渲染,直接转交 Caption 服务(拼接视频+混入音频+叠加字幕)
if len(templates) < 1 {
return "", fmt.Errorf("至少需要1个HTML模板")
g.Log().Infof(ctx, "[模板解析] templates 为空, 跳过模板逻辑, 直接拼接视频+音频+字幕")
return Caption.CreateAsyncTask(ctx, videoURLs, audioURL, subtitles, subtitleStyle, nil, callbackURL)
}
// 创建临时目录用于下载模板和图片