修复diffMs,和offset判断
This commit is contained in:
parent
ba4aad0ae5
commit
fcf1e28fbd
@ -7,10 +7,7 @@ type File struct {
|
||||
Url string `json:"url"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
DiffMs int64 `json:"diffMs"`
|
||||
StartTime time.Time `json:"startTime"`
|
||||
EndTime time.Time `json:"endTime"`
|
||||
}
|
||||
|
||||
func (f *File) GetDiffMs() int64 {
|
||||
return f.EndTime.Sub(f.StartTime).Milliseconds()
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"ZhenTuLocalPassiveAdapter/config"
|
||||
"ZhenTuLocalPassiveAdapter/dto"
|
||||
"bytes"
|
||||
"fmt"
|
||||
@ -142,11 +141,6 @@ func CheckFileCoverageAndConstructTask(fileList []dto.File, beginDt, endDt time.
|
||||
OutputFile: os.TempDir() + "/" + task.TaskID + ".mp4",
|
||||
}
|
||||
|
||||
if ffmpegTask.Offset > (config.Config.Record.Duration) {
|
||||
log.Printf("分析FFMPEG任务失败:ID:【%s】,文件片段:【%s】,无法完整覆盖时间点【%s】", task.TaskID, fileList[len(fileList)-1].Name, endDt)
|
||||
return nil, fmt.Errorf("无法完整覆盖时间点")
|
||||
}
|
||||
|
||||
return ffmpegTask, nil
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ func FilterAndSortFiles(fileList []dto.File, beginDt, endDt time.Time) []dto.Fil
|
||||
fileStartTime := file.StartTime
|
||||
nextFileStartTime := file.EndTime
|
||||
|
||||
file.DiffMs = fileStartTime.Sub(beginDt).Milliseconds()
|
||||
// 如果当前文件还没有开始
|
||||
if beginDt.After(fileStartTime) {
|
||||
// 没有下一个文件的情况下,就是最后一个文件
|
||||
@ -34,7 +35,7 @@ func FilterAndSortFiles(fileList []dto.File, beginDt, endDt time.Time) []dto.Fil
|
||||
|
||||
// 按照 GetDiffMs 的值降序排序
|
||||
sort.Slice(filteredFiles, func(i, j int) bool {
|
||||
return filteredFiles[i].GetDiffMs() > filteredFiles[j].GetDiffMs()
|
||||
return filteredFiles[i].DiffMs > filteredFiles[j].DiffMs
|
||||
})
|
||||
|
||||
return filteredFiles
|
||||
|
Loading…
x
Reference in New Issue
Block a user