Skip to content

Commit

Permalink
[demuxers/Matroska] Fix calculation of CFR timestamps for given timeb…
Browse files Browse the repository at this point in the history
…ase when the first frame PTS significantly deviates from a multiple of the timebase
  • Loading branch information
eumagga0x2a committed Aug 14, 2021
1 parent 0cd87d1 commit dd54650
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions avidemux_plugins/ADM_demuxers/Matroska/ADM_mkv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,13 @@ bool mkvHeader::enforceFixedFrameRate(int num, int den)
dmultiple*=den;
dmultiple/=(1000000.*(double)num);
zero=((uint64_t)dmultiple*1000000*num)/den;
track->index[first].Pts=zero;
}
ADM_info("Num=%d Den=%d half=%d zero=%d first=%d\n",num,den,half,(int)zero,first);
for(int i=first+1;i<nb;i++)
{
uint64_t pts=track->index[i].Pts;
if(pts<zero) continue;
pts-=zero;
if(pts < track->index[first].Pts) continue;
pts-=track->index[first].Pts;
double dmultiple=(pts+half);
dmultiple*=den;
dmultiple/=(1000000.*(double)num);
Expand All @@ -447,6 +446,8 @@ bool mkvHeader::enforceFixedFrameRate(int num, int den)
#endif
track->index[i].Pts=reconstructed;
}
track->index[first].Pts = zero;

_videostream.dwScale=num;
_videostream.dwRate=den;
double f=num;
Expand Down

0 comments on commit dd54650

Please sign in to comment.