[Bf-blender-cvs] [53ef03d] master: FFmpeg: Experiment with use of nb_frames from a stream when known

Sergey Sharybin noreply at git.blender.org
Thu Jan 28 16:40:47 CET 2016


Commit: 53ef03d20f5ce1dc0c6cb49c759f0be3f467340f
Author: Sergey Sharybin
Date:   Thu Jan 28 16:38:05 2016 +0100
Branches: master
https://developer.blender.org/rB53ef03d20f5ce1dc0c6cb49c759f0be3f467340f

FFmpeg: Experiment with use of nb_frames from a stream when known

The idea is to use known number of frames in the stream when possible
instead of trying to deduct it from a stream duration and time base,
which could potentially give some rounding errors.

This, i.e., solves quicktime encoded files from animators to open
just fine in sequencer.

Another report done by the main Nieve guy (aka venomgfx)

===================================================================

M	source/blender/imbuf/intern/anim_movie.c

===================================================================

diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index d5ff427..4ace72d 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -525,9 +525,14 @@ static int startffmpeg(struct anim *anim)
 	}
 
 	frame_rate = av_get_r_frame_rate_compat(pFormatCtx->streams[videoStream]);
-	anim->duration = ceil(pFormatCtx->duration *
-	                      av_q2d(frame_rate) /
-	                      AV_TIME_BASE);
+	if (pFormatCtx->streams[videoStream]->nb_frames != 0) {
+		anim->duration = pFormatCtx->streams[videoStream]->nb_frames;
+	}
+	else {
+		anim->duration = ceil(pFormatCtx->duration *
+		                      av_q2d(frame_rate) /
+		                      AV_TIME_BASE);
+	}
 
 	frs_num = frame_rate.num;
 	frs_den = frame_rate.den;




More information about the Bf-blender-cvs mailing list