From dc0b6dd9fa8f42ab81b249791fa7132d1bfd432b Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Wed, 1 Oct 2008 21:17:06 +0000 Subject: [PATCH] ffms2: fix CFR->VFR conversion bug Originally committed to SVN as r2406. --- FFmpegSource2/ffvideosource.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FFmpegSource2/ffvideosource.cpp b/FFmpegSource2/ffvideosource.cpp index c816451b1..246758dfd 100644 --- a/FFmpegSource2/ffvideosource.cpp +++ b/FFmpegSource2/ffvideosource.cpp @@ -110,7 +110,7 @@ VideoBase::~VideoBase() { } AVFrameLite *VideoBase::GetFrameByTime(double Time, char *ErrorMsg, unsigned MsgSize) { - int Frame = Frames.ClosestFrameFromDTS((Time * Frames.TB.Num) / Frames.TB.Den + 0.5); + int Frame = Frames.ClosestFrameFromDTS((Time * 1000 * Frames.TB.Den) / Frames.TB.Num); return GetFrame(Frame, ErrorMsg, MsgSize); } @@ -236,8 +236,8 @@ FFVideoSource::FFVideoSource(const char *SourceFile, int Track, FrameIndex *Trac VP.FPSNumerator = FormatContext->streams[VideoTrack]->time_base.den; VP.NumFrames = Frames.size(); VP.PixelFormat = CodecContext->pix_fmt; - VP.FirstTime = (Frames.front().DTS * Frames.TB.Den) / (double)Frames.TB.Num; - VP.LastTime = (Frames.back().DTS * Frames.TB.Den) / (double)Frames.TB.Num; + VP.FirstTime = ((Frames.front().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; + VP.LastTime = ((Frames.back().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; if (VP.Width <= 0 || VP.Height <= 0) { Free(true); @@ -455,8 +455,8 @@ MatroskaVideoSource::MatroskaVideoSource(const char *SourceFile, int Track, VP.FPSNumerator = 30; VP.NumFrames = Frames.size(); VP.PixelFormat = CodecContext->pix_fmt; - VP.FirstTime = (Frames.front().DTS * Frames.TB.Den) / (double)Frames.TB.Num; - VP.LastTime = (Frames.back().DTS * Frames.TB.Den) / (double)Frames.TB.Num; + VP.FirstTime = ((Frames.front().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; + VP.LastTime = ((Frames.back().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; if (VP.Width <= 0 || VP.Height <= 0) { Free(true);