summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-19 02:42:53 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-08-19 02:42:53 +0200
commitaf5086087e35eeeb4e6cac5882638aa278ea9833 (patch)
treee636910be03b92f9aeb901b177c8dff10f8240b9 /ffmpeg.c
parent0de4918f32ffbc43d205c924301515585d71068b (diff)
ffmpeg: Clip invalid video timestamps like audio instead of failing hard.
Fixes Ticket976 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 860499a1f3..2851254ec6 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -505,11 +505,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
(avctx->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
- if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) {
+ if ((avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) && pkt->dts != AV_NOPTS_VALUE) {
int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
if (ost->st->cur_dts && ost->st->cur_dts != AV_NOPTS_VALUE && max > pkt->dts) {
- av_log(s, max - pkt->dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt->dts, max);
- pkt->pts = pkt->dts = max;
+ av_log(s, max - pkt->dts > 2 || avctx->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG,
+ "st:%d PTS: %"PRId64" DTS: %"PRId64" < %"PRId64" invalid, cliping\n", pkt->stream_index, pkt->pts, pkt->dts, max);
+ if(pkt->pts >= pkt->dts)
+ pkt->pts = FFMAX(pkt->pts, max);
+ pkt->dts = max;
}
}