Browse code

avformat/movenc: check that the input timestamps are within the range that can be stored in mov

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/02/21 10:30:19
Showing 1 changed files
... ...
@@ -3255,6 +3255,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
3255 3255
     int size = pkt->size;
3256 3256
     uint8_t *reformatted_data = NULL;
3257 3257
 
3258
+    if (trk->entry) {
3259
+        int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts;
3260
+        if (duration < 0 || duration > INT_MAX) {
3261
+            av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n",
3262
+                duration, pkt->dts
3263
+            );
3264
+
3265
+            pkt->dts = trk->cluster[trk->entry - 1].dts + 1;
3266
+            pkt->pts = AV_NOPTS_VALUE;
3267
+        }
3268
+    }
3258 3269
     if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
3259 3270
         int ret;
3260 3271
         if (mov->fragments > 0) {