summaryrefslogtreecommitdiff
path: root/rotord/src/libavwrapper.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-08-08 13:32:46 +0100
committerTim Redfern <tim@herge.(none)>2013-08-08 13:32:46 +0100
commita2254447b138af7fc0719e5a107816487255736b (patch)
treefc72463364bd158b5a042ac821766f466efdfcb0 /rotord/src/libavwrapper.cpp
parent1f8aca919df6ab2d2636cddaa30de1e388b4c09d (diff)
basic speed control for video_loader
Diffstat (limited to 'rotord/src/libavwrapper.cpp')
-rwxr-xr-xrotord/src/libavwrapper.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp
index 7c00b91..c21d077 100755
--- a/rotord/src/libavwrapper.cpp
+++ b/rotord/src/libavwrapper.cpp
@@ -223,6 +223,10 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 )
pCtx->time_base.den = 1000;
+ framerate=(((float)container->streams[videoStream]->r_frame_rate.num)/((float)container->streams[videoStream]->r_frame_rate.den));
+
+ //cerr<<"codecContext timebase: "<<(((float)pCtx->time_base.num)/((float)pCtx->time_base.den))<<" videostream framerate: "<<(((float)container->streams[videoStream]->r_frame_rate.num)/((float)container->streams[videoStream]->r_frame_rate.den))<<endl;
+
//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;
@@ -240,8 +244,7 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
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 );
+ numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * framerate );
//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
}