修改cf渠道 火山视频生成时间问题
This commit is contained in:
@@ -505,6 +505,18 @@ func (s *VideoGenerationService) GenerateVideoFromImage(imageGenID uint) (*model
|
||||
return nil, fmt.Errorf("image is not ready")
|
||||
}
|
||||
|
||||
// 获取关联的Storyboard以获取时长
|
||||
var duration *int
|
||||
if imageGen.StoryboardID != nil {
|
||||
var storyboard models.Storyboard
|
||||
if err := s.db.Where("id = ?", *imageGen.StoryboardID).First(&storyboard).Error; err == nil {
|
||||
duration = &storyboard.Duration
|
||||
s.log.Infow("Using storyboard duration for video generation",
|
||||
"storyboard_id", *imageGen.StoryboardID,
|
||||
"duration", storyboard.Duration)
|
||||
}
|
||||
}
|
||||
|
||||
req := &GenerateVideoRequest{
|
||||
DramaID: fmt.Sprintf("%d", imageGen.DramaID),
|
||||
StoryboardID: imageGen.StoryboardID,
|
||||
@@ -512,6 +524,7 @@ func (s *VideoGenerationService) GenerateVideoFromImage(imageGenID uint) (*model
|
||||
ImageURL: *imageGen.ImageURL,
|
||||
Prompt: imageGen.Prompt,
|
||||
Provider: "doubao",
|
||||
Duration: duration,
|
||||
}
|
||||
|
||||
return s.GenerateVideo(req)
|
||||
|
||||
@@ -146,13 +146,23 @@ func (c *ChatfireClient) GenerateVideo(imageURL, prompt string, opts ...VideoOpt
|
||||
reqBody := ChatfireDoubaoRequest{
|
||||
Model: model,
|
||||
}
|
||||
|
||||
// 构建prompt文本(包含duration和ratio参数)
|
||||
promptText := prompt
|
||||
if options.AspectRatio != "" {
|
||||
promptText += fmt.Sprintf(" --ratio %s", options.AspectRatio)
|
||||
}
|
||||
if options.Duration > 0 {
|
||||
promptText += fmt.Sprintf(" --dur %d", options.Duration)
|
||||
}
|
||||
|
||||
// 添加文本内容
|
||||
reqBody.Content = append(reqBody.Content, struct {
|
||||
Type string `json:"type"`
|
||||
Text string `json:"text,omitempty"`
|
||||
ImageURL map[string]interface{} `json:"image_url,omitempty"`
|
||||
Role string `json:"role,omitempty"`
|
||||
}{Type: "text", Text: prompt})
|
||||
}{Type: "text", Text: promptText})
|
||||
|
||||
// 处理不同的图片模式
|
||||
// 1. 组图模式(多个reference_image)
|
||||
|
||||
Reference in New Issue
Block a user