视频剪辑和处理
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package video
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
dto "media/model/dto/video"
|
||||
service "media/service/video"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type caption struct{}
|
||||
|
||||
var Caption = new(caption)
|
||||
|
||||
// CreateCaption 创建字幕叠加任务 POST /video/caption
|
||||
func (c *caption) CreateCaption(ctx context.Context, req *dto.CreateCaptionTaskReq) (res *dto.CreateCaptionTaskRes, err error) {
|
||||
ctx = withUser(ctx)
|
||||
g.Log().Infof(ctx, "[字幕叠加] 收到请求 入参: video_count=%d, element_count=%d, callback=%s",
|
||||
len(req.VideoURLs), len(req.Elements), req.CallbackURL)
|
||||
|
||||
if len(req.VideoURLs) < 1 {
|
||||
return nil, fmt.Errorf("至少需要1个视频")
|
||||
}
|
||||
|
||||
taskID, taskErr := service.Caption.CreateAsyncTask(ctx, req.VideoURLs, req.AudioURL, req.Subtitles, req.SubtitleStyle, req.Elements, req.CallbackURL)
|
||||
if taskErr != nil {
|
||||
return nil, taskErr
|
||||
}
|
||||
|
||||
return &dto.CreateCaptionTaskRes{TaskID: taskID}, nil
|
||||
}
|
||||
|
||||
// GetCaptionTask 查询字幕任务结果 GET /video/caption/{taskId}
|
||||
func (c *caption) GetCaptionTask(ctx context.Context, req *dto.GetCaptionTaskReq) (res *dto.GetCaptionTaskRes, err error) {
|
||||
ctx = withUser(ctx)
|
||||
return service.Caption.GetTaskResult(ctx, req.TaskID)
|
||||
}
|
||||
Reference in New Issue
Block a user