File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 1717namespace facebook ::torchcodec {
1818namespace {
1919
20- double ptsToSeconds (int64_t pts, int den) {
21- return static_cast <double >(pts) / den;
22- }
23-
2420double ptsToSeconds (int64_t pts, const AVRational& timeBase) {
25- return ptsToSeconds (pts, timeBase.den ) ;
21+ return static_cast < double > (pts) * timeBase.num / timeBase. den ;
2622}
2723
2824int64_t secondsToClosestPts (double seconds, const AVRational& timeBase) {
29- return static_cast <int64_t >(std::round (seconds * timeBase.den ));
25+ return static_cast <int64_t >(
26+ std::round (seconds * timeBase.den / timeBase.num ));
3027}
3128
3229} // namespace
@@ -152,7 +149,7 @@ void SingleStreamDecoder::initializeDecoder() {
152149
153150 if (formatContext_->duration > 0 ) {
154151 containerMetadata_.durationSeconds =
155- ptsToSeconds (formatContext_->duration , AV_TIME_BASE );
152+ ptsToSeconds (formatContext_->duration , AV_TIME_BASE_Q );
156153 }
157154
158155 if (formatContext_->bit_rate > 0 ) {
You can’t perform that action at this time.
0 commit comments