From f85ec9a68e6fab7265c3c2b78ab0fabf8310dacd Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 3 Jul 2013 15:41:25 +0100 Subject: squashed frame retieval bug --- rotord/libavwrapper.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'rotord/libavwrapper.cpp') diff --git a/rotord/libavwrapper.cpp b/rotord/libavwrapper.cpp index 97315a6..08d943f 100755 --- a/rotord/libavwrapper.cpp +++ b/rotord/libavwrapper.cpp @@ -211,9 +211,30 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam) if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 ) pCtx->time_base.den = 1000; + //cerr<<"stream frame rate:"<streams[videoStream]->r_frame_rate.num<<"/"<streams[videoStream]->r_frame_rate.den<duration<time_base.num<<"/"<time_base.den<duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5); + //numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5); + //this approach just seems wrong! + + + + numFrames=container->streams[videoStream]->nb_frames-1; + + if (numFrames<1){ + //some codecs don't keep this info in the header + float fr=((float)container->streams[videoStream]->r_frame_rate.num)/container->streams[videoStream]->r_frame_rate.den; + numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * fr ); + //this approach still doesn't seem to give quite the right answer- comes out a little too big + //could alternatively just redefine the length if the reader fails + } + + init_buffers_and_scaler(); -- cgit v1.2.3