修改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")
|
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{
|
req := &GenerateVideoRequest{
|
||||||
DramaID: fmt.Sprintf("%d", imageGen.DramaID),
|
DramaID: fmt.Sprintf("%d", imageGen.DramaID),
|
||||||
StoryboardID: imageGen.StoryboardID,
|
StoryboardID: imageGen.StoryboardID,
|
||||||
@@ -512,6 +524,7 @@ func (s *VideoGenerationService) GenerateVideoFromImage(imageGenID uint) (*model
|
|||||||
ImageURL: *imageGen.ImageURL,
|
ImageURL: *imageGen.ImageURL,
|
||||||
Prompt: imageGen.Prompt,
|
Prompt: imageGen.Prompt,
|
||||||
Provider: "doubao",
|
Provider: "doubao",
|
||||||
|
Duration: duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.GenerateVideo(req)
|
return s.GenerateVideo(req)
|
||||||
|
|||||||
@@ -146,13 +146,23 @@ func (c *ChatfireClient) GenerateVideo(imageURL, prompt string, opts ...VideoOpt
|
|||||||
reqBody := ChatfireDoubaoRequest{
|
reqBody := ChatfireDoubaoRequest{
|
||||||
Model: model,
|
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 {
|
reqBody.Content = append(reqBody.Content, struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
ImageURL map[string]interface{} `json:"image_url,omitempty"`
|
ImageURL map[string]interface{} `json:"image_url,omitempty"`
|
||||||
Role string `json:"role,omitempty"`
|
Role string `json:"role,omitempty"`
|
||||||
}{Type: "text", Text: prompt})
|
}{Type: "text", Text: promptText})
|
||||||
|
|
||||||
// 处理不同的图片模式
|
// 处理不同的图片模式
|
||||||
// 1. 组图模式(多个reference_image)
|
// 1. 组图模式(多个reference_image)
|
||||||
|
|||||||
Reference in New Issue
Block a user