summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-13 05:13:34 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-13 17:29:23 +0200
commit8f5bb35f4004791a6eb69049103a1c6382cf6542 (patch)
treec0da1ab471fd29d824548963d636584cd5fea6b8 /ffmpeg.c
parentfbbe092568e942f76b3baea43b575e47325d6655 (diff)
ffmpeg: fix video synchronization code to be exact on constant fps videos. Fixes Ticket137
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 20f8db0ce3..b887abd7f5 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1220,9 +1220,18 @@ static void do_video_out(AVFormatContext *s,
AVFrame *final_picture;
AVCodecContext *enc;
double sync_ipts;
+ double duration = 0;
enc = ost->st->codec;
+ if (ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE) {
+ duration = FFMAX(av_q2d(ist->st->time_base), av_q2d(ist->st->codec->time_base));
+ if(ist->st->avg_frame_rate.num)
+ duration= FFMAX(duration, 1/av_q2d(ist->st->avg_frame_rate));
+
+ duration /= av_q2d(enc->time_base);
+ }
+
sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
/* by default, we output a single frame */
@@ -1235,7 +1244,7 @@ static void do_video_out(AVFormatContext *s,
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? 2 : 1;
if (format_video_sync) {
- double vdelta = sync_ipts - ost->sync_opts;
+ double vdelta = sync_ipts - ost->sync_opts + duration;
//FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (vdelta < -1.1)
nb_frames = 0;