Documentation
¶
Overview ¶
Package subtitle 提供字幕处理功能
本包实现了多种字幕格式的解析和处理:
- SRT (SubRip) 格式
- ASS/SSA (Advanced SubStation Alpha) 格式
- WebVTT (Web Video Text Tracks) 格式
- CEA-608/708 隐藏字幕提取
支持字幕烧录(硬字幕)和软字幕封装。
Index ¶
Constants ¶
View Source
const ( CEA708ServicePrimary = 1 // 主字幕服务 CEA708ServiceSecondary = 2 // 次字幕服务 )
CEA708 服务类型
Variables ¶
View Source
var ( ErrInvalidFormat = errors.New("subtitle: invalid format") ErrInvalidTimestamp = errors.New("subtitle: invalid timestamp") ErrEmptySubtitle = errors.New("subtitle: empty subtitle") ErrUnsupportedCodec = errors.New("subtitle: unsupported codec") )
错误定义
Functions ¶
This section is empty.
Types ¶
type Burner ¶
type Burner struct {
// contains filtered or unexported fields
}
Burner 字幕烧录器
func (*Burner) BurnFrame ¶
BurnFrame 在帧上烧录字幕
type BurnerConfig ¶
type BurnerConfig struct {
FontSize float64 // 字体大小
FontColor color.Color // 字体颜色
OutlineColor color.Color // 轮廓颜色
OutlineWidth int // 轮廓宽度
ShadowColor color.Color // 阴影颜色
ShadowOffset int // 阴影偏移
MarginBottom int // 底部边距
MarginSide int // 侧边距
Alignment int // 对齐方式 (1=左, 2=中, 3=右)
LineSpacing int // 行间距
}
BurnerConfig 字幕烧录配置
type CEA608Channel ¶
type CEA608Channel int
CEA608Channel CEA-608 频道
const ( CEA608CC1 CEA608Channel = iota // 字幕频道 1 CEA608CC2 // 字幕频道 2 CEA608CC3 // 字幕频道 3 (文本) CEA608CC4 // 字幕频道 4 (文本) )
type CEA608Extractor ¶
type CEA608Extractor struct {
// contains filtered or unexported fields
}
CEA608Extractor CEA-608 字幕提取器
func NewCEA608Extractor ¶
func NewCEA608Extractor() *CEA608Extractor
NewCEA608Extractor 创建 CEA-608 提取器
func (*CEA608Extractor) GetSubtitle ¶
func (e *CEA608Extractor) GetSubtitle() *Subtitle
GetSubtitle 获取提取的字幕
type CEA708Extractor ¶
type CEA708Extractor struct {
// contains filtered or unexported fields
}
CEA708Extractor CEA-708 字幕提取器
func NewCEA708Extractor ¶
func NewCEA708Extractor() *CEA708Extractor
NewCEA708Extractor 创建 CEA-708 提取器
func (*CEA708Extractor) GetSubtitle ¶
func (e *CEA708Extractor) GetSubtitle() *Subtitle
GetSubtitle 获取提取的字幕
type CEA708Window ¶
type CEA708Window struct {
ID int
Visible bool
RowLock bool
ColLock bool
Priority int
RelativePos bool
AnchorV int
AnchorH int
AnchorPoint int
RowCount int
ColCount int
PenStyle int
WindowStyle int
// 内容
Text bytes.Buffer
Row int
Col int
}
CEA708Window 窗口定义
type Cue ¶
type Cue struct {
Index int // 序号
StartTime time.Duration // 开始时间
EndTime time.Duration // 结束时间
Text string // 文本内容
Style *Style // 样式(可选)
Position *Position // 位置(可选)
}
Cue 字幕条目
type FrameProcessor ¶
BurnSubtitle 便捷函数:烧录整个字幕到视频帧序列
func CreateBurnProcessor ¶
func CreateBurnProcessor(sub *Subtitle, config BurnerConfig) FrameProcessor
CreateBurnProcessor 创建烧录处理器
type Position ¶
type Position struct {
X int // X 坐标
Y int // Y 坐标
Align string // 对齐方式
Line int // 行号
Size float64 // 大小百分比
Vertical bool // 垂直排列
}
Position 字幕位置
type Style ¶
type Style struct {
Name string // 样式名称
FontName string // 字体名称
FontSize float64 // 字体大小
Bold bool // 粗体
Italic bool // 斜体
Underline bool // 下划线
StrikeOut bool // 删除线
PrimaryColor string // 主颜色 (ARGB)
SecondaryColor string // 次颜色
OutlineColor string // 轮廓颜色
BackColor string // 背景颜色
BorderStyle int // 边框样式
Outline float64 // 轮廓宽度
Shadow float64 // 阴影深度
Alignment int // 对齐方式
MarginL int // 左边距
MarginR int // 右边距
MarginV int // 垂直边距
}
Style 字幕样式
Source Files
¶
- burner.go
- cea608.go
- cea708.go
- subtitle.go
Click to show internal directories.
Click to hide internal directories.