Browse Source

判断 ffmpeg 是否导出当前版本的缓存字幕和音频信息,没有则清理后再导出

Signed-off-by: allan716 <[email protected]>
allan716 4 years ago
parent
commit
905113b854

+ 1 - 0
internal/pkg/ffmpeg_helper/audio_info.go

@@ -13,6 +13,7 @@ type AudioInfo struct {
 	timeBase  string
 	startTime string
 	language  string
+	FullPath  string
 }
 
 func NewAudioInfo(index int, codecName, codecType, timeBase, startTime, language string) *AudioInfo {

+ 1 - 1
internal/pkg/ffmpeg_helper/ffmpeg_helper.go

@@ -144,7 +144,7 @@ func (f *FFMPEGHelper) parseJsonString2GetFFMPEGInfo(videoFileFullPath, inputFFP
 					continue
 				}
 			}
-			subInfo := NewSubtitileInfo(int(oneIndex.Num), oneCodecName.String(), oneCodecType.String(),
+			subInfo := NewSubtitleInfo(int(oneIndex.Num), oneCodecName.String(), oneCodecType.String(),
 				oneTimeBase.String(), oneStartTime.String(),
 				int(oneDurationTS.Num), oneDuration.String(), nowLanguageString)
 

+ 15 - 6
internal/pkg/ffmpeg_helper/ffmpeg_info.go

@@ -37,20 +37,29 @@ func (f *FFMPEGInfo) IsExported() bool {
 		return false
 	}
 	// 字幕都要导出了
-	for _, subtitleInfo := range f.SubtitleInfoList {
+	for index, subtitleInfo := range f.SubtitleInfoList {
 
-		if pkg.IsFile(filepath.Join(nowCacheFolder, subtitleInfo.GetName()+common.SubExtSRT)) == false {
+		subSrtFPath := filepath.Join(nowCacheFolder, subtitleInfo.GetName()+common.SubExtSRT)
+		if pkg.IsFile(subSrtFPath) == false {
 			return false
+		} else {
+			f.SubtitleInfoList[index].FullPath = subSrtFPath
 		}
-		if pkg.IsFile(filepath.Join(nowCacheFolder, subtitleInfo.GetName()+common.SubExtASS)) == false {
+		subASSFPath := filepath.Join(nowCacheFolder, subtitleInfo.GetName()+common.SubExtASS)
+		if pkg.IsFile(subASSFPath) == false {
 			return false
+		} else {
+			f.SubtitleInfoList[index].FullPath = subASSFPath
 		}
+
 	}
 	// 音频是否导出了
-	for _, audioInfo := range f.AudioInfoList {
-
-		if pkg.IsFile(filepath.Join(nowCacheFolder, audioInfo.GetName()+extPCM)) == false {
+	for index, audioInfo := range f.AudioInfoList {
+		audioFPath := filepath.Join(nowCacheFolder, audioInfo.GetName()+extPCM)
+		if pkg.IsFile(audioFPath) == false {
 			return false
+		} else {
+			f.AudioInfoList[index].FullPath = audioFPath
 		}
 	}
 

+ 2 - 1
internal/pkg/ffmpeg_helper/subtitile_info.go

@@ -16,9 +16,10 @@ type SubtitleInfo struct {
 	duration   string
 	language   string
 	content    string
+	FullPath   string
 }
 
-func NewSubtitileInfo(index int, codecName, codecType, timeBase, startTime string, durationTS int, duration, language string) *SubtitleInfo {
+func NewSubtitleInfo(index int, codecName, codecType, timeBase, startTime string, durationTS int, duration, language string) *SubtitleInfo {
 	return &SubtitleInfo{
 		Index:      index,
 		CodecName:  codecName,