aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-04-11 20:24:00 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-04-13 02:12:22 +0200
commitbd3ea317976820bf921f44c3829a2c48f80823fa (patch)
treea7ec98808e15017f2eaefa9410c9270db2160370 /ffmpeg.c
parentca19862d3879dfadfd6c1a1a443eac40fc433385 (diff)
downloadffmpeg-bd3ea317976820bf921f44c3829a2c48f80823fa.tar.gz
ffmpeg: Compensate non monotonicity errors in the audio TSs.
Audio timestamps are passed through by default and when the input doesnt contain clean timestamps this can lead to non monotonicity errors. (rounding to a course timebase can cause this too) Print a warning when the errors in the timestamps are large Fixes Ticket1167 (regression since timestamps are passed through) This is a generic workaround that is intended to handle slightly incorrect input files. It is very possible that some demuxers contain bugs that lead to wrong timestamps, these demuxers should of course still be fixed even if this change happens to hide the issue. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 093d7cc9fc..f5025b0be0 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1132,8 +1132,14 @@ static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,
if (got_packet) {
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
- if (pkt.dts != AV_NOPTS_VALUE)
+ if (pkt.dts != AV_NOPTS_VALUE) {
+ int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
+ 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;
+ }
+ }
if (pkt.duration > 0)
pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);