fix(personal): persist placeholders for video edit and extension jobs

media_jobs requires non-empty seconds/size/quality, so edit/extend now store stable placeholders while upstream still omits generation-only fields.
This commit is contained in:
lindahao committed 2026-08-13 09:09:08 +08:00
1 parent 55078cd588
commit bb4394eef5
1 file changed
+15 -3
+15 -3
View File
@@ -93,6 +93,13 @@ func (s *Service) CreateVideo(ctx context.Context, input VideoInput) (media.Job,
if operation == provider.VideoOperationEdit && input.Duration != 0 {
return media.Job{}, fmt.Errorf("视频编辑不支持 duration")
}
if operation == provider.VideoOperationEdit {
// Official edit has no duration field. Persist a placeholder that
// satisfies media_jobs.seconds CHECK (1-15); worker ignores it.
if input.Duration == 0 {
input.Duration = 1
}
}
if operation == provider.VideoOperationExtend {
if input.Duration == 0 {
input.Duration = 6
@@ -101,9 +108,14 @@ func (s *Service) CreateVideo(ctx context.Context, input VideoInput) (media.Job,
return media.Job{}, fmt.Errorf("视频延长 duration 必须在 2 到 10 秒之间")
}
}
// Edit/extend keep source geometry; ignore generation-only knobs.
input.AspectRatio = ""
input.Resolution = ""
// Edit/extend keep source geometry upstream, but media_jobs still requires
// non-empty size/quality columns. Store stable placeholders only.
if strings.TrimSpace(input.AspectRatio) == "" {
input.AspectRatio = "source"
}
if strings.TrimSpace(input.Resolution) == "" {
input.Resolution = "source"
}
}
allRefs := videoInputReferences(input.ImageURL, input.ReferenceURLs)
if err := s.validateVideoInputReferences(ctx, allRefs); err != nil {