Compare commits
2 Commits
cf3c518d13
...
f9256895b7
Author | SHA1 | Date | |
---|---|---|---|
f9256895b7 | |||
104930c413 |
@ -51,7 +51,10 @@ func (l *LocalAdapter) GetFileList(ctx context.Context, dirPath string, relDt ti
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if startTime.Equal(stopTime) || stopTime.IsZero() {
|
||||
if stopTime.IsZero() {
|
||||
stopTime = startTime
|
||||
}
|
||||
if startTime.Equal(stopTime) {
|
||||
// 如果文件名没有时间戳,则认为该文件是未录制完成的
|
||||
// 尝试读取一下视频信息
|
||||
duration, err := util.GetVideoDuration(subCtx, path.Join(l.StorageConfig.Path, dirPath, file.Name()))
|
||||
|
@ -91,7 +91,10 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time.
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if startTime.Equal(stopTime) || stopTime.IsZero() {
|
||||
if stopTime.IsZero() {
|
||||
stopTime = startTime
|
||||
}
|
||||
if startTime.Equal(stopTime) {
|
||||
stopTime = stopTime.Add(time.Second * time.Duration(config.Config.Record.Duration))
|
||||
}
|
||||
presignClient := s3.NewPresignClient(client)
|
||||
|
@ -461,12 +461,11 @@ func GetVideoDuration(ctx context.Context, filePath string) (float64, error) {
|
||||
span.SetStatus(codes.Error, "failed to get video duration")
|
||||
return 0, fmt.Errorf("failed to get video duration: %w", err)
|
||||
}
|
||||
span.SetAttributes(attribute.String("ffmpeg.stdout", out.String()))
|
||||
span.SetAttributes(attribute.String("ffprobe.stdout", out.String()))
|
||||
durationStr := strings.TrimSpace(out.String())
|
||||
duration, err := strconv.ParseFloat(durationStr, 64)
|
||||
if err != nil {
|
||||
span.SetAttributes(attribute.String("error", err.Error()))
|
||||
span.SetStatus(codes.Error, "failed to parse video duration")
|
||||
return 0, fmt.Errorf("failed to parse video duration: %w", err)
|
||||
}
|
||||
span.SetAttributes(attribute.Float64("video.duration", duration))
|
||||
|
Loading…
x
Reference in New Issue
Block a user