diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-09-13 05:13:34 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-13 17:29:23 +0200 |
commit | 8f5bb35f4004791a6eb69049103a1c6382cf6542 (patch) | |
tree | c0da1ab471fd29d824548963d636584cd5fea6b8 /ffmpeg.c | |
parent | fbbe092568e942f76b3baea43b575e47325d6655 (diff) | |
download | ffmpeg-8f5bb35f4004791a6eb69049103a1c6382cf6542.tar.gz |
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.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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; |