movdec: Make sure the stream duration is set based on stts instead of mdhd

Message ID 1328192840-20536-1-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Feb. 2, 2012, 2:27 p.m.
For fragmented files, st->duration is used for setting dts on all
packets in later fragments. In those cases, after parsing the moov
atom, st->duration should be the duration of all samples described
within the moov, not the duration of the complete file.

For some ismv files, the mdhd duration is the total duration of the
files, not only the duration of the samples in the moov atom
(which doesn't contain any samples at all).

This fixes part of bug 215.
---
 libavformat/mov.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Luca Barbato Feb. 6, 2012, 7:53 p.m. | #1
On 2/2/12 9:27 AM, Martin Storsjö wrote:
> -    st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
> +    (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */

Uhm, might be marked better. like /* skip duration */

beside that ok.

lu
Martin Storsjö Feb. 6, 2012, 7:56 p.m. | #2
On Mon, 6 Feb 2012, Luca Barbato wrote:

> On 2/2/12 9:27 AM, Martin Storsjö wrote:
>> -    st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* 
>> duration */
>> +    (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
>
> Uhm, might be marked better. like /* skip duration */
>
> beside that ok.

Janne fixed it in a better way, so these both patches are dropped (I 
marked them as superseded on patchwork, but perhaps I should have 
mentioned it in a mail here, too).

But yes, it might have fixed some other issues with fragmented files, too.

// Martin

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8723695..a83ffe4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -747,7 +747,7 @@  static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     mov_metadata_creation_time(&st->metadata, creation_time);
 
     sc->time_scale = avio_rb32(pb);
-    st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
+    (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
 
     lang = avio_rb16(pb); /* language */
     if (ff_mov_lang_to_iso639(lang, language))