ffmpeg_helper

package
v0.55.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Subtitle_StreamCodec_subrip = "subrip"
	Subtitle_StreamCodec_ass    = "ass"
	Subtitle_StreamCodec_ssa    = "ssa"
	Subtitle_StreamCodec_srt    = "srt"
)

FFMPEG 支持的字幕 Codec Name:

..S... arib_caption         ARIB STD-B24 caption
DES... ass                  ASS (Advanced SSA) subtitle (decoders: ssa ass ) (encoders: ssa ass )
DES... dvb_subtitle         DVB subtitles (decoders: dvbsub ) (encoders: dvbsub )
..S... dvb_teletext         DVB teletext
DES... dvd_subtitle         DVD subtitles (decoders: dvdsub ) (encoders: dvdsub )
D.S... eia_608              EIA-608 closed captions (decoders: cc_dec )
D.S... hdmv_pgs_subtitle    HDMV Presentation Graphic Stream subtitles (decoders: pgssub )
..S... hdmv_text_subtitle   HDMV Text subtitle
D.S... jacosub              JACOsub subtitle
D.S... microdvd             MicroDVD subtitle
DES... mov_text             MOV text
D.S... mpl2                 MPL2 subtitle
D.S... pjs                  PJS (Phoenix Japanimation Society) subtitle
D.S... realtext             RealText subtitle
D.S... sami                 SAMI subtitle
..S... srt                  SubRip subtitle with embedded timing
..S... ssa                  SSA (SubStation Alpha) subtitle
D.S... stl                  Spruce subtitle format
DES... subrip               SubRip subtitle (decoders: srt subrip ) (encoders: srt subrip )
D.S... subviewer            SubViewer subtitle
D.S... subviewer1           SubViewer v1 subtitle
DES... text                 raw UTF-8 text
..S... ttml                 Timed Text Markup Language
D.S... vplayer              VPlayer subtitle
DES... webvtt               WebVTT subtitle
DES... xsub                 XSUB

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioInfo

type AudioInfo struct {
	Index     int
	CodecName string
	CodecType string

	FullPath string
	Duration float64
	// contains filtered or unexported fields
}

func NewAudioInfo

func NewAudioInfo(index int, codecName, codecType, timeBase, startTime, language string) *AudioInfo

func (AudioInfo) GetLanguage

func (a AudioInfo) GetLanguage() language2.MyLanguage

GetLanguage 获取音频的语言类型

func (AudioInfo) GetName

func (a AudioInfo) GetName() string

GetName 获取音频名称,这里以音频的名称(中文)+ 索引的位置类描述

type ExportType

type ExportType int
const (
	Subtitle         ExportType = iota // 导出字幕
	Audio                              // 导出音频
	SubtitleAndAudio                   // 导出字幕和音频
)

type FFMPEGHelper

type FFMPEGHelper struct {
	SubParserHub *sub_parser_hub.SubParserHub // 字幕内容的解析器
	// contains filtered or unexported fields
}

func NewFFMPEGHelper

func NewFFMPEGHelper(log *logrus.Logger) *FFMPEGHelper

func (*FFMPEGHelper) ExportAudioAndSubArgsByTimeRange

func (f *FFMPEGHelper) ExportAudioAndSubArgsByTimeRange(audioFullPath, subFullPath string, startTimeString, timeLength string) (string, string, string, error)

ExportAudioAndSubArgsByTimeRange 根据输入的时间轴导出音频分段信息 "0:1:27" "28.2"

func (*FFMPEGHelper) ExportAudioDurationInfo

func (f *FFMPEGHelper) ExportAudioDurationInfo(audioFileFullPath string) (bool, float64, error)

ExportAudioDurationInfo 获取音频的长度信息

func (*FFMPEGHelper) ExportFFMPEGInfo

func (f *FFMPEGHelper) ExportFFMPEGInfo(videoFileFullPath string, exportType ExportType) (bool, *FFMPEGInfo, error)

ExportFFMPEGInfo 获取 视频的 FFMPEG 信息,包含音频和字幕 优先会导出 中、英、日、韩 类型的,字幕如果没有语言类型,则也导出,然后需要额外的字幕语言的判断去辅助标记(读取文件内容) 音频只会导出一个,优先导出 中、英、日、韩 类型的

func (*FFMPEGHelper) ExportSubArgsByTimeRange

func (f *FFMPEGHelper) ExportSubArgsByTimeRange(subFullPath, outName string, startTimeString, timeLength string) (string, string, error)

ExportSubArgsByTimeRange 根据输入的时间轴导出字幕分段信息 "0:1:27" "28.2"

func (*FFMPEGHelper) ExportVideoHLSAndSubByTimeRange

func (f *FFMPEGHelper) ExportVideoHLSAndSubByTimeRange(videoFullPath string, subFullPaths []string, startTimeString, timeLength, segmentTime, outDirPath string) (string, []string, error)

ExportVideoHLSAndSubByTimeRange 导出指定的时间轴的视频HLS和字幕,然后从 outDirPath 中获取 outputlist.m3u8 和字幕的文件

func (*FFMPEGHelper) GetVideoDuration

func (f *FFMPEGHelper) GetVideoDuration(videoFileFullPath string) float64

func (*FFMPEGHelper) Version

func (f *FFMPEGHelper) Version() (string, error)

Version 获取版本信息,如果不存在 FFMPEG 和 ffprobe 则报错

type FFMPEGInfo

type FFMPEGInfo struct {
	VideoFullPath    string                // 视频文件的路径
	Duration         float64               // 视频的时长
	AudioInfoList    []AudioInfo           // 内置音频列表
	SubtitleInfoList []SubtitleInfo        // 内置字幕列表
	ExternalSubInfos []*subparser.FileInfo // 外置字幕列表
	// contains filtered or unexported fields
}

func NewFFMPEGInfo

func NewFFMPEGInfo(log *logrus.Logger, videoFullPath string) *FFMPEGInfo

func (*FFMPEGInfo) CreateExportedMask

func (f *FFMPEGInfo) CreateExportedMask() error

func (*FFMPEGInfo) GetCacheFolderFPath

func (f *FFMPEGInfo) GetCacheFolderFPath() (string, error)

GetCacheFolderFPath 获取缓存文件夹的绝对路径,存储在通用的 SubFixCacheFolder 中 csf-cache/当前的视频文件名(不带后缀)

func (*FFMPEGInfo) GetExternalSubInfos

func (f *FFMPEGInfo) GetExternalSubInfos(subParserHub *sub_parser_hub.SubParserHub) error

GetExternalSubInfos 获取外置的字幕信息

func (*FFMPEGInfo) IsExported

func (f *FFMPEGInfo) IsExported(exportType ExportType) bool

IsExported 是否已经导出过,如果没有导出或者导出不完整为 false

type SubtitleInfo

type SubtitleInfo struct {
	Index     int
	CodecName string
	CodecType string

	FullPath string
	// contains filtered or unexported fields
}

func NewSubtitleInfo

func NewSubtitleInfo(index int, codecName, codecType, timeBase, startTime string, durationTS int, duration, language string) *SubtitleInfo

func (SubtitleInfo) GetLanguage

func (s SubtitleInfo) GetLanguage() language2.MyLanguage

GetLanguage 获取字幕语言的类型

func (SubtitleInfo) GetName

func (s SubtitleInfo) GetName() string

GetName 获取字幕名称,这里以语言的名称(中文)+ 索引的位置类描述

func (*SubtitleInfo) SetContent

func (s *SubtitleInfo) SetContent(content string) error

SetContent 设置字幕的内容,同时进行字幕语言的判断

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL