Compare commits

..

No commits in common. "f9256895b7564511102bfd7905eb76765589786f" and "cf3c518d13de5104f12a525f8d6ac111a84e3c6c" have entirely different histories.

3 changed files with 4 additions and 9 deletions

View File

@ -51,10 +51,7 @@ func (l *LocalAdapter) GetFileList(ctx context.Context, dirPath string, relDt ti
if err != nil {
continue
}
if stopTime.IsZero() {
stopTime = startTime
}
if startTime.Equal(stopTime) {
if startTime.Equal(stopTime) || stopTime.IsZero() {
// 如果文件名没有时间戳,则认为该文件是未录制完成的
// 尝试读取一下视频信息
duration, err := util.GetVideoDuration(subCtx, path.Join(l.StorageConfig.Path, dirPath, file.Name()))

View File

@ -91,10 +91,7 @@ func (s *S3Adapter) GetFileList(ctx context.Context, dirPath string, relDt time.
if err != nil {
continue
}
if stopTime.IsZero() {
stopTime = startTime
}
if startTime.Equal(stopTime) {
if startTime.Equal(stopTime) || stopTime.IsZero() {
stopTime = stopTime.Add(time.Second * time.Duration(config.Config.Record.Duration))
}
presignClient := s3.NewPresignClient(client)

View File

@ -461,11 +461,12 @@ 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("ffprobe.stdout", out.String()))
span.SetAttributes(attribute.String("ffmpeg.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))