Skip to content

Commit

Permalink
fix first packet's pts bug with --read-length
Browse files Browse the repository at this point in the history
- calculates pts from next packet if value is missing
  • Loading branch information
GabrielChanzy committed Aug 1, 2023
1 parent c46ccc0 commit 1a97986
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ffmpeg_bitrate_stats/bitrate_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ def _calculate_frame_sizes(self) -> list[FrameEntry]:
}
)
idx += 1

# fix for missing pts in first packet (occurs when reading streams)
if self.read_length and ret[0]["pts"] == "NaN":
ret[0]["pts"] = ret[1]["pts"] - ret[0]["duration"]

# fix for missing durations, estimate it via PTS
if default_duration == "NaN":
Expand Down

0 comments on commit 1a97986

Please sign in to comment.