diff options
Diffstat (limited to 'rotord/libavwrapper.cpp')
| -rwxr-xr-x | rotord/libavwrapper.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
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:"<<container->streams[videoStream]->r_frame_rate.num<<"/"<<container->streams[videoStream]->r_frame_rate.den<<endl; + + //cerr<<"video duration: "<<container->duration<<endl; + //cerr<<"video time base: "<<pCtx->time_base.num<<"/"<<pCtx->time_base.den<<endl; + //cerr<<"AV time base: "<<AV_TIME_BASE<<endl; + /* Compute the total number of frames in the file */ /* duration is in microsecs */ - numFrames = (int)(( container->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(); |
