]> git.sesse.net Git - ffmpeg/commitdiff
lavc/videotoolboxenc: Fix DTS
authorRick Kern <kernrj@gmail.com>
Wed, 27 Apr 2016 14:53:09 +0000 (10:53 -0400)
committerwm4 <nfxjfg@googlemail.com>
Wed, 4 May 2016 16:40:40 +0000 (18:40 +0200)
Some devices output an invalid DTS when B-frames aren't used. Using PTS for
the DTS in this case.

Signed-off-by: Rick Kern <kernrj@gmail.com>
libavcodec/videotoolboxenc.c

index 25c9648bcb28b927bc9c41b6eacb17e59f297f7f..72c7ba899473c11f2fefdc6ab7b15ac83acd8fd5 100644 (file)
@@ -1034,6 +1034,15 @@ static int vtenc_cm_to_avpacket(
     pts = CMSampleBufferGetPresentationTimeStamp(sample_buffer);
     dts = CMSampleBufferGetDecodeTimeStamp      (sample_buffer);
 
+    if (CMTIME_IS_INVALID(dts)) {
+        if (!vtctx->has_b_frames) {
+            dts = pts;
+        } else {
+            av_log(avctx, AV_LOG_ERROR, "DTS is invalid.\n");
+            return AVERROR_EXTERNAL;
+        }
+    }
+
     dts_delta = vtctx->dts_delta >= 0 ? vtctx->dts_delta : 0;
     time_base_num = avctx->time_base.num;
     pkt->pts = pts.value / time_base_num;