[FFmpeg-devel] [PATCH] lavf/mov: ignore ctts entries that do not apply to a least one sample

Matthieu Bouron matthieu.bouron at gmail.com
Thu Jun 16 17:26:14 CEST 2016


From: Matthieu Bouron <matthieu.bouron at stupeflix.com>

Fixes packet pts of samples which contain ctts entries with count=0.
---

Hello,

The following patch fixes packet pts of samples which contain ctts values with
count=0 (so the ctts entry does not apply to any sample if I understand
correctly). Such samples are produced by a LG G4 phone. I don't have any
sample I can share at the moment (and thus no fate test following this patch
yet).

An alternative to this patch is to remove directly the entry when the ctts atom
is parsed. Would you prefer this alternative ?

What happens without the patch is that the ctts_index is never incremented if
the current ctts entry count is 0.

Matthieu

---
 libavformat/mov.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 57a0354..7fbad22 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5175,6 +5175,11 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = sc->ffindex;
     pkt->dts = sample->timestamp;
+
+    if (sc->ctts_data && sc->ctts_index < sc->ctts_count &&
+        sc->ctts_data[sc->ctts_index].count == 0)
+        sc->ctts_index++;
+
     if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
         pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;
         /* update ctts context */
-- 
2.8.3



More information about the ffmpeg-devel mailing list