subtitile_info.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package ffmpeg_helper
  2. import (
  3. "fmt"
  4. "github.com/allanpk716/ChineseSubFinder/internal/pkg/language"
  5. language2 "github.com/allanpk716/ChineseSubFinder/internal/types/language"
  6. )
  7. type SubtitleInfo struct {
  8. Index int
  9. CodecName string
  10. CodecType string
  11. timeBase string
  12. startTime string
  13. durationTS int
  14. duration string
  15. language string
  16. content string
  17. FullPath string
  18. }
  19. func NewSubtitleInfo(index int, codecName, codecType, timeBase, startTime string, durationTS int, duration, language string) *SubtitleInfo {
  20. return &SubtitleInfo{
  21. Index: index,
  22. CodecName: codecName,
  23. CodecType: codecType,
  24. timeBase: timeBase,
  25. startTime: startTime,
  26. durationTS: durationTS,
  27. duration: duration,
  28. language: language,
  29. }
  30. }
  31. // SetContent 设置字幕的内容,同时进行字幕语言的判断
  32. func (s *SubtitleInfo) SetContent(content string) error {
  33. s.content = content
  34. return nil
  35. }
  36. // GetLanguage 获取字幕语言的类型
  37. func (s SubtitleInfo) GetLanguage() language2.MyLanguage {
  38. return language.ISOString2SupportLang(s.language)
  39. }
  40. // GetName 获取字幕名称,这里以语言的名称(中文)+ 索引的位置类描述
  41. func (s SubtitleInfo) GetName() string {
  42. return fmt.Sprintf("%s_%d", language.Lang2ChineseString(s.GetLanguage()), s.Index)
  43. }