aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-09-23 01:06:30 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-09-23 01:38:12 +0200
commit22844132069ebd2c0b2ac4e7b41c93c33890bfb9 (patch)
tree2617a694f5a0bb7184e0d83a1b592d433bc53ee7
parentbdb7f08666832838474c37c4b71f29c98f8bbcb2 (diff)
downloadffmpeg-22844132069ebd2c0b2ac4e7b41c93c33890bfb9.tar.gz
ffmpeg: replace impossible dts/pts combinations by a reasonable guess instead of hard failing
Fixes stream copy from tserror270.ts Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index ee8039cce8..47a414455b 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -659,6 +659,17 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
}
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
+ if (pkt->dts != AV_NOPTS_VALUE &&
+ pkt->pts != AV_NOPTS_VALUE &&
+ pkt->dts > pkt->pts) {
+ av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n",
+ pkt->dts, pkt->pts,
+ ost->file_index, ost->st->index);
+ pkt->pts =
+ pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1
+ - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1)
+ - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1);
+ }
if(
(avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->dts != AV_NOPTS_VALUE &&
@@ -681,15 +692,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
pkt->dts = max;
}
}
- if (pkt->dts != AV_NOPTS_VALUE &&
- pkt->pts != AV_NOPTS_VALUE &&
- pkt->dts > pkt->pts) {
- av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d\n",
- pkt->dts, pkt->pts,
- ost->file_index, ost->st->index);
- pkt->pts = AV_NOPTS_VALUE;
- pkt->dts = AV_NOPTS_VALUE;
- }
}
ost->last_mux_dts = pkt->dts;