From 266b42f1c0cfaa0e44f328d9fd523612fce6022e Mon Sep 17 00:00:00 2001
From: Oana Stratulat <oanaandreeastratulat@gmail.com>
Date: Wed, 11 Jan 2012 03:50:12 +0200
Subject: [PATCH] Fixes wrong duration in .mov file. Issue 599

---
 libavformat/mov.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 05521fd..884079c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -791,6 +791,8 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     av_dlog(c->fc, "time scale = %i\n", c->time_scale);
 
     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
+    //Set the AVFormatContext duration because the track duration is not accurate
+    c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
     avio_rb32(pb); /* preferred scale */
 
     avio_rb16(pb); /* preferred volume */
-- 
1.7.5.4

