main.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package main
  2. import (
  3. "time"
  4. "github.com/ChineseSubFinder/ChineseSubFinder/pkg"
  5. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/log_helper"
  6. "github.com/sirupsen/logrus"
  7. )
  8. /*
  9. 字幕时间轴修复命令行
  10. 使用方法:
  11. go run main.go -vp ${videoPath} -sp ${subtitlePath}
  12. ${videPath} -> 视频文件路径,需要指定对应的视频文件
  13. ${subtitlePath} -> 字幕文件路径,需要指定对应的字幕文件
  14. 逻辑:
  15. 1. 执行 SubTimelineFixerHelperEx 检查 - 确认已经安装了ffmpeg 和 ffprobe
  16. 2. 执行 SubTimelineFixerHelperEx 的 process操作
  17. 编译:
  18. 通过`go build -o fixer`编译出可直接执行的文件。
  19. */
  20. var loggerBase *logrus.Logger
  21. func newLog() *logrus.Logger {
  22. logger := log_helper.NewLogHelper(log_helper.LogNameCliSubTimelineFixer,
  23. pkg.ConfigRootDirFPath(),
  24. logrus.InfoLevel, time.Duration(7*24)*time.Hour, time.Duration(24)*time.Hour)
  25. return logger
  26. }
  27. func main() {
  28. //var videoPath string
  29. //var subtitlesPath string
  30. loggerBase = newLog()
  31. //videoPath = "X:\\连续剧\\All Creatures Great and Small (2020)\\Season 1\\All Creatures Great and Small (2020) - S01E04 - A Tricki Case WEBDL-1080p.mkv"
  32. ////videoPath = "X:\\连续剧\\All Creatures Great and Small (2020)\\Season 1\\All Creatures Great and Small (2020) - S01E05 - All's Fair WEBDL-1080p.mkv"
  33. ////subtitlesPath = "D:\\Subtitle\\123.ass"
  34. ////subtitlesPath = "D:\\Subtitle\\123.srt"
  35. ////subtitlesPath = "D:\\Subtitle\\英_2.srt"
  36. //subtitlesPath = "D:\\Subtitle\\All Creatures Great and Small (2020) - S01E04 - A Tricki Case WEBDL-1080p.chinese(简,manual).default.srt"
  37. //
  38. //var fixerSetting = settings.NewTimelineFixerSettings()
  39. //fixerSetting.ThreadCount = 1
  40. //fixerSetting.MinOffset = 3
  41. //var subTimelineFixerHelper = sub_timeline_fixer.NewSubTimelineFixerHelperEx(loggerBase, *fixerSetting)
  42. //if subTimelineFixerHelper.Check() {
  43. // err := subTimelineFixerHelper.Process(videoPath, subtitlesPath, sub_timeline_fixer.ProcessTypeByAudioFile)
  44. // if err != nil {
  45. // println(err)
  46. // }
  47. //} else {
  48. // println("check subtitles timeline fixer helper failed.")
  49. //}
  50. //
  51. //println("Done.")
  52. //app := &cli.App{
  53. // Name: "Subtitle Timeline Fixer",
  54. // Usage: "Fix the subtitle timeline according to the video",
  55. // Flags: []cli.Flag{
  56. // &cli.StringFlag{
  57. // Name: "videoPath",
  58. // Aliases: []string{"vp"},
  59. // Usage: "Specify `video file path`",
  60. // Destination: &videoPath,
  61. // Required: true,
  62. // },
  63. //
  64. // &cli.StringFlag{
  65. // Name: "subtitlesPath",
  66. // Aliases: []string{"sp"},
  67. // Usage: "Specify `subtitles file path`",
  68. // Destination: &subtitlesPath,
  69. // Required: true,
  70. // },
  71. // },
  72. // Action: func(c *cli.Context) error {
  73. // videoPath = strings.TrimSpace(videoPath)
  74. // subtitlesPath = strings.TrimSpace(subtitlesPath)
  75. // if videoPath != "" && subtitlesPath != "" {
  76. // var fixerSetting = settings.NewTimelineFixerSettings()
  77. // var subTimelineFixerHelper = sub_timeline_fixer.NewSubTimelineFixerHelperEx(loggerBase, *fixerSetting)
  78. // if subTimelineFixerHelper.Check() {
  79. // subTimelineFixerHelper.Process(videoPath, subtitlesPath)
  80. // } else {
  81. // println("check subtitles timeline fixer helper failed.")
  82. // }
  83. // } else {
  84. // println("need provide video path (-vp) and subtitle path (-sp)")
  85. // }
  86. // return nil
  87. // },
  88. //}
  89. //
  90. //err := app.Run(os.Args)
  91. //if err != nil {
  92. // log.Fatal(err)
  93. //}
  94. }