diff --git a/controller/video/template_controller.go b/controller/video/template_controller.go index d4fc0a4..084da74 100644 --- a/controller/video/template_controller.go +++ b/controller/video/template_controller.go @@ -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 { diff --git a/model/dto/video/video_template_dto.go b/model/dto/video/video_template_dto.go index 5d5a688..e9f2894 100644 --- a/model/dto/video/video_template_dto.go +++ b/model/dto/video/video_template_dto.go @@ -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:"任务完成后的回调地址(可选)"` diff --git a/service/video/template_service.go b/service/video/template_service.go index 4c96fe8..7b9b91b 100644 --- a/service/video/template_service.go +++ b/service/video/template_service.go @@ -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) } // 创建临时目录用于下载模板和图片