]> git.sesse.net Git - mlt/commitdiff
use rational fps value to calc frames count
authorMaksym Veremeyenko <verem@m1stereo.tv>
Thu, 18 Jul 2013 12:03:40 +0000 (15:03 +0300)
committerDan Dennedy <dan@dennedy.org>
Tue, 30 Jul 2013 04:35:39 +0000 (21:35 -0700)
src/modules/avformat/producer_avformat.c

index 3dab6165de3c38852200c8ac9e3b243a4757561e..9d6881d471cd6401813b5f4e4e4d3d2216871f7c 100644 (file)
@@ -575,10 +575,6 @@ static int get_basic_info( producer_avformat self, mlt_profile profile, const ch
 
        AVFormatContext *format = self->video_format;
 
-       // We will treat everything with the producer fps.
-       // TODO: make this more flexible.
-       double fps = mlt_profile_fps( profile );
-
        // Get the duration
        if ( !mlt_properties_get_int( properties, "_length_computed" ) )
        {
@@ -587,7 +583,9 @@ static int get_basic_info( producer_avformat self, mlt_profile profile, const ch
                if ( format->duration != AV_NOPTS_VALUE )
                {
                        // This isn't going to be accurate for all formats
-                       mlt_position frames = ( mlt_position )( ( ( double )format->duration / ( double )AV_TIME_BASE ) * fps );
+                       // We will treat everything with the producer fps.
+                       mlt_position frames = ( mlt_position )( int )( format->duration *
+                               profile->frame_rate_num / profile->frame_rate_den / AV_TIME_BASE);
                        mlt_properties_set_position( properties, "out", frames - 1 );
                        mlt_properties_set_position( properties, "length", frames );
                        mlt_properties_set_int( properties, "_length_computed", 1 );