From 279ebd8c70b3ff154e336d32b1e72894640b6e0d Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Thu, 18 Jul 2013 15:03:40 +0300 Subject: [PATCH] use rational fps value to calc frames count --- src/modules/avformat/producer_avformat.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index 3dab6165..9d6881d4 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -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 ); -- 2.39.2