Skip to content

Commit 709cf08

Browse files
committed
fix(encoder): decreasing PTS precision with increasing video duration (#1269)
Signed-off-by: k4yt3x <i@k4yt3x.com>
1 parent bf5917b commit 709cf08

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- The issue of decreasing PTS precision with increasing video duration (#1269).
13+
814
## [6.3.0] - 2024-12-20
915

1016
### Added

src/encoder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
262262
frame->pict_type = AV_PICTURE_TYPE_NONE;
263263

264264
// Calculate this frame's presentation timestamp (PTS)
265-
frame->pts = frame_idx * (enc_ctx_->time_base.den * enc_ctx_->framerate.den /
266-
(enc_ctx_->time_base.num * enc_ctx_->framerate.num));
265+
frame->pts = av_rescale_q(frame_idx, av_inv_q(enc_ctx_->framerate), enc_ctx_->time_base);
267266

268267
// Convert the frame to the encoder's pixel format if needed
269268
if (frame->format != enc_ctx_->pix_fmt) {

0 commit comments

Comments
 (0)