Skip to content

Commit

Permalink
fix: more reliable frame duration
Browse files Browse the repository at this point in the history
  • Loading branch information
connerdouglass committed Mar 10, 2024
1 parent d68bcd3 commit 5337874
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions metadata/ffprobe_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type StreamMeta struct {
RFrameRate string `json:"r_frame_rate"`
AvgFrameRate string `json:"avg_frame_rate"`
TimeBase string `json:"time_base"`
StartPts int `json:"start_pts"`
StartPts int64 `json:"start_pts"`
StartTime string `json:"start_time"`
DurationTs int `json:"duration_ts"`
DurationTs int64 `json:"duration_ts"`
Duration string `json:"duration"`
BitRate string `json:"bit_rate"`
BitsPerRawSample string `json:"bits_per_raw_sample"`
Expand Down Expand Up @@ -123,11 +123,14 @@ func (m *Meta) GetLengthFrames() int64 {
if video == nil {
return 0
}
frames, err := strconv.ParseInt(video.NbFrames, 10, 64)
if err != nil {
return 0
if video.NbFrames != "" {
frames, err := strconv.ParseInt(video.NbFrames, 10, 64)
if err != nil {
return 0
}
return frames
}
return frames
return video.DurationTs
}

// GetDurationSeconds gets the duration of the media in seconds.
Expand Down

0 comments on commit 5337874

Please sign in to comment.