summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-02-07 11:03:33 +0100
committerAnton Khirnov <anton@khirnov.net>2012-02-26 07:48:45 +0100
commit832ba44d8d91d5c5ad47843085f810bde74a2e6d (patch)
tree6a43af2787cd300759e2fdc9006e78ab19d9a13b /avconv.c
parent87d7a92b62ad9b582afa0d4006c5a387e7a1bdac (diff)
avconv: saner output video timebase.
r_frame_rate should in theory have something to do with input framerate, but in practice it is often made up from thin air by lavf. So unless we are targeting a constant output framerate, it's better to just use input stream timebase. Brings back dropped frames in nuv and cscd tests introduced in cd1ad18a6539bd7fc2dc4c1740fbcbd498c0c0a2
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/avconv.c b/avconv.c
index 8310f7374b..7acd7ed597 100644
--- a/avconv.c
+++ b/avconv.c
@@ -2450,13 +2450,30 @@ static int transcode_init(OutputFile *output_files,
ost->resample_width = icodec->width;
ost->resample_pix_fmt = icodec->pix_fmt;
- if (!ost->frame_rate.num)
- ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational) { 25, 1 };
- if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {
- int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
- ost->frame_rate = ost->enc->supported_framerates[idx];
+ /*
+ * We want CFR output if and only if one of those is true:
+ * 1) user specified output framerate with -r
+ * 2) user specified -vsync cfr
+ * 3) output format is CFR and the user didn't force vsync to
+ * something else than CFR
+ *
+ * in such a case, set ost->frame_rate
+ */
+ if (!ost->frame_rate.num &&
+ (video_sync_method == VSYNC_CFR ||
+ (video_sync_method == VSYNC_AUTO &&
+ !(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) {
+ ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1};
+ if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {
+ int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
+ ost->frame_rate = ost->enc->supported_framerates[idx];
+ }
}
- codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
+ if (ost->frame_rate.num) {
+ codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
+ video_sync_method = VSYNC_CFR;
+ } else
+ codec->time_base = ist->st->time_base;
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {