[FFmpeg-cvslog] avconv: stop using setpts for input framerate forced with -r
Anton Khirnov
git at videolan.org
Sun Mar 12 14:11:08 EET 2017
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jul 15 06:50:47 2016 +0200| [b0f36a0043d76436cc7ab8ff92ab99c94595d3c0] | committer: Anton Khirnov
avconv: stop using setpts for input framerate forced with -r
The setpts filter does not signal to the rest of the filtergraph that
the stream is CFR. Just generate the timestamps manually instead.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b0f36a0043d76436cc7ab8ff92ab99c94595d3c0
---
avconv.c | 2 ++
avconv.h | 5 +++++
avconv_filter.c | 19 ++-----------------
configure | 2 +-
4 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/avconv.c b/avconv.c
index 3a7a898..57c02ac 100644
--- a/avconv.c
+++ b/avconv.c
@@ -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;
diff --git a/avconv.h b/avconv.h
index cffe114..fcdf3d0 100644
--- a/avconv.h
+++ b/avconv.h
@@ -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;
diff --git a/avconv_filter.c b/avconv_filter.c
index 96277f8..b78d3bd 100644
--- a/avconv_filter.c
+++ b/avconv_filter.c
@@ -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);
@@ -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) ?
diff --git a/configure b/configure
index 37c5611..5885519 100755
--- a/configure
+++ b/configure
@@ -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"
More information about the ffmpeg-cvslog
mailing list