File tree 1 file changed +4
-7
lines changed
1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 17
17
namespace facebook ::torchcodec {
18
18
namespace {
19
19
20
- double ptsToSeconds (int64_t pts, int den) {
21
- return static_cast <double >(pts) / den;
22
- }
23
-
24
20
double ptsToSeconds (int64_t pts, const AVRational& timeBase) {
25
- return ptsToSeconds (pts, timeBase.den ) ;
21
+ return static_cast < double > (pts) * timeBase.num / timeBase. den ;
26
22
}
27
23
28
24
int64_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 ));
30
27
}
31
28
32
29
} // namespace
@@ -152,7 +149,7 @@ void SingleStreamDecoder::initializeDecoder() {
152
149
153
150
if (formatContext_->duration > 0 ) {
154
151
containerMetadata_.durationSeconds =
155
- ptsToSeconds (formatContext_->duration , AV_TIME_BASE );
152
+ ptsToSeconds (formatContext_->duration , AV_TIME_BASE_Q );
156
153
}
157
154
158
155
if (formatContext_->bit_rate > 0 ) {
You can’t perform that action at this time.
0 commit comments