Files
media/model/dto/video/video_caption_dto.go
T
2026-06-25 16:48:18 +08:00

79 lines
4.2 KiB
Go

package video
import "github.com/gogf/gf/v2/frame/g"
// ---------- 字幕元素定义 ----------
// CaptionElement 单个字幕/图片元素
type CaptionElement struct {
Type string `json:"type" v:"required#元素类型必填" dc:"元素类型:text/image"`
Text string `json:"text" dc:"文字内容(type=text时必填)"`
ImageURL string `json:"imageUrl" dc:"图片URL(type=image时必填)"`
StartTime float64 `json:"startTime" d:"0" dc:"开始时间(秒,默认0)"`
Duration float64 `json:"duration" d:"0" dc:"持续时长(秒,0或空=一直显示到视频结束)"`
X string `json:"x" d:"center" dc:"水平位置:left/center/right或像素值"`
Y string `json:"y" d:"center" dc:"垂直位置:top/center/bottom或像素值"`
FontSize int `json:"fontSize" d:"36" dc:"字号(type=text有效)"`
FontColor string `json:"fontColor" d:"#FFFFFF" dc:"字体颜色"`
BgColor string `json:"bgColor" dc:"背景色,如#FFFF00,空=透明"`
BgOpacity float64 `json:"bgOpacity" d:"1.0" dc:"背景透明度0-1"`
Width int `json:"width" dc:"元素宽度(type=image有效)"`
Height int `json:"height" dc:"元素高度(type=image有效)"`
Animation string `json:"animation" dc:"动画效果:fadeIn/slideUp/slideLeft/scaleIn"`
TrackIndex int `json:"trackIndex" d:"1" dc:"轨道层级(数字越大越靠前)"`
}
// SubtitleSegment 外部传入的字幕时间线片段
type SubtitleSegment struct {
Start float64 `json:"start" v:"required#开始时间必填" dc:"开始时间(秒)"`
End float64 `json:"end" v:"required#结束时间必填" dc:"结束时间(秒)"`
Text string `json:"text" v:"required#字幕文本必填" dc:"字幕文本内容"`
}
// SubtitleStyle 字幕样式配置
type SubtitleStyle struct {
FontSize int `json:"fontSize" d:"48" dc:"字号(默认48)"`
FontColor string `json:"fontColor" d:"#FFFFFF" dc:"字体颜色(默认白色)"`
BgColor *string `json:"bgColor" dc:"背景色,空字符串=透明(默认#000000)。传空字符串 '' 可去掉背景色"`
BgOpacity *float64 `json:"bgOpacity" dc:"背景透明度0-1(默认0.4)。传0可使背景完全透明"`
X string `json:"x" d:"center" dc:"水平位置:left/center/right或像素值(默认center)"`
Y string `json:"y" d:"65%" dc:"垂直位置:top/center/bottom或像素值或百分比(默认65%)"`
}
// ---------- 创建字幕任务 ----------
// CreateCaptionTaskReq 创建字幕叠加任务请求
type CreateCaptionTaskReq struct {
g.Meta `path:"/" method:"post" tags:"字幕叠加" summary:"创建字幕叠加任务(异步)" dc:"创建使用HyperFrames渲染的视频字幕叠加任务,返回taskId"`
VideoURLs []string `json:"video_urls" v:"required#视频URL列表不能为空" dc:"背景视频URL列表"`
AudioURL string `json:"audio_url" dc:"背景音频URL(可选)"`
Subtitles []SubtitleSegment `json:"subtitles" dc:"字幕时间线列表(可选),每段包含起始时间和文本"`
SubtitleStyle *SubtitleStyle `json:"subtitle_style" dc:"字幕样式配置(可选),不传则使用默认值"`
Elements []CaptionElement `json:"elements" dc:"字幕/图片元素列表(可选)"`
CallbackURL string `json:"callback_url" dc:"任务完成后的回调地址(可选)"`
}
// CreateCaptionTaskRes 创建字幕任务响应
type CreateCaptionTaskRes struct {
TaskID string `json:"taskId" dc:"任务ID"`
}
// ---------- 查询字幕任务 ----------
// GetCaptionTaskReq 查询字幕任务请求
type GetCaptionTaskReq struct {
g.Meta `path:"/{taskId}" method:"get" tags:"字幕叠加" summary:"查询字幕任务结果" dc:"根据taskId查询字幕任务详情"`
TaskID string `json:"taskId" dc:"任务ID"`
}
// GetCaptionTaskRes 查询字幕任务响应
type GetCaptionTaskRes struct {
TaskID string `json:"taskId" dc:"任务ID"`
Status string `json:"status" dc:"任务状态"`
FileURL string `json:"fileUrl,omitempty" dc:"输出文件URL"`
FileSize int64 `json:"fileSize,omitempty" dc:"输出文件大小"`
FileName string `json:"fileName,omitempty" dc:"输出文件名"`
DurationStr string `json:"durationStr,omitempty" dc:"视频时长"`
ErrorMessage string `json:"errorMessage,omitempty" dc:"错误信息"`
}