Skip to content

Commit

Permalink
avconv: stop using setpts for input framerate forced with -r
Browse files Browse the repository at this point in the history
The setpts filter does not signal to the rest of the filtergraph that
the stream is CFR. Just generate the timestamps manually instead.
  • Loading branch information
elenril committed Jul 22, 2016
1 parent 9064777 commit b0f36a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 2 additions & 0 deletions avconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)

decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pts,
decoded_frame->pkt_dts);
if (ist->framerate.num)
decoded_frame->pts = ist->cfr_next_pts++;

if (ist->st->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
Expand Down
5 changes: 5 additions & 0 deletions avconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ typedef struct InputStream {
int64_t last_dts;
int64_t min_pts; /* pts with the smallest value in a current stream */
int64_t max_pts; /* pts with the higher value in a current stream */

// when forcing constant input framerate through -r,
// this contains the pts that will be given to the next decoded frame
int64_t cfr_next_pts;

int64_t nb_samples; /* number of samples in the last decoded audio frame before looping */
PtsCorrectionContext pts_ctx;
double ts_scale;
Expand Down
19 changes: 2 additions & 17 deletions avconv_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
par->height = ifilter->height;
par->format = ifilter->format;
par->time_base = tb;
if (ist->framerate.num)
par->frame_rate = ist->framerate;
par->hw_frames_ctx = ifilter->hw_frames_ctx;

ret = av_buffersrc_parameters_set(ifilter->filter, par);
Expand Down Expand Up @@ -552,23 +554,6 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
}
}

if (ist->framerate.num) {
AVFilterContext *setpts;

snprintf(name, sizeof(name), "force CFR for input from stream %d:%d",
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&setpts,
avfilter_get_by_name("setpts"),
name, "N", NULL,
fg->graph)) < 0)
return ret;

if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)
return ret;

last_filter = setpts;
}

snprintf(name, sizeof(name), "trim for input stream %d:%d",
ist->file_index, ist->st->index);
ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,7 @@ swscale_deps="avutil"
avconv_deps="avcodec avfilter avformat avresample swscale"
avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
fps_filter null_filter resample_filter scale_filter
setpts_filter trim_filter"
trim_filter"
avplay_deps="avcodec avfilter avformat avresample sdl"
avplay_libs='$sdl_libs'
avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
Expand Down

0 comments on commit b0f36a0

Please sign in to comment.