diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-08-21 11:37:10 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-08-21 11:37:10 +0200 |
commit | b69b075ac607419a840da798b089de8ea7630d4b (patch) | |
tree | 8f3476fc1f20bc3d81813b18a0d4ea4bdfe3cb82 /libavfilter | |
parent | 58e12732dbab77fe06b861dcbdc712c5fa065bbd (diff) | |
parent | 545a0b807cf45b2bbc4c9087a297b741ce00f508 (diff) | |
download | ffmpeg-b69b075ac607419a840da798b089de8ea7630d4b.tar.gz |
Merge commit '545a0b807cf45b2bbc4c9087a297b741ce00f508'
* commit '545a0b807cf45b2bbc4c9087a297b741ce00f508':
vf_fps: add 'start_time' option
Conflicts:
doc/filters.texi
libavfilter/vf_fps.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_fps.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index 006c24577f..e30e90b394 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -44,6 +44,8 @@ typedef struct FPSContext { int64_t first_pts; ///< pts of the first frame that arrived on this filter int64_t pts; ///< pts of the first frame currently in the fifo + double start_time; ///< pts, in seconds, of the expected first frame + AVRational framerate; ///< target framerate int rounding; ///< AVRounding method for timestamps @@ -59,6 +61,7 @@ typedef struct FPSContext { #define F AV_OPT_FLAG_FILTERING_PARAM static const AVOption fps_options[] = { { "fps", "A string describing desired output framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, .flags = V|F }, + { "start_time", "Assume the first PTS should be this value.", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = AV_NOPTS_VALUE}, INT64_MIN, INT64_MAX, V }, { "round", "set rounding method for timestamps", OFFSET(rounding), AV_OPT_TYPE_INT, { .i64 = AV_ROUND_NEAR_INF }, 0, 5, V|F, "round" }, { "zero", "round towards 0", OFFSET(rounding), AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_ZERO }, 0, 5, V|F, "round" }, { "inf", "round away from 0", OFFSET(rounding), AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_INF }, 0, 5, V|F, "round" }, @@ -78,6 +81,7 @@ static av_cold int init(AVFilterContext *ctx) return AVERROR(ENOMEM); s->pts = AV_NOPTS_VALUE; + s->first_pts = AV_NOPTS_VALUE; av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", s->framerate.num, s->framerate.den); return 0; @@ -178,7 +182,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) if (ret < 0) return ret; - s->first_pts = s->pts = buf->pts; + if (s->start_time != AV_NOPTS_VALUE) { + double first_pts = s->start_time * AV_TIME_BASE; + first_pts = FFMIN(FFMAX(first_pts, INT64_MIN), INT64_MAX); + s->first_pts = s->pts = av_rescale_q(first_pts, AV_TIME_BASE_Q, + inlink->time_base); + av_log(ctx, AV_LOG_VERBOSE, "Set first pts to (in:%"PRId64" out:%"PRId64")\n", + s->first_pts, av_rescale_q(first_pts, AV_TIME_BASE_Q, + outlink->time_base)); + } else { + s->first_pts = s->pts = buf->pts; + } } else { av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no " "timestamp.\n"); |