diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2013-03-16 12:21:14 +0100 |
---|---|---|
committer | Nicolas George <nicolas.george@normalesup.org> | 2013-03-20 20:59:45 +0100 |
commit | 68fb7e260bcd9ecd666dded95bb19db8c2898388 (patch) | |
tree | 040aac712edc6199940cd68a05ce6ee2aecb69d5 /libavfilter | |
parent | de1a71595de778000611abc0ee3941df2248a990 (diff) | |
download | ffmpeg-streaming-68fb7e260bcd9ecd666dded95bb19db8c2898388.zip ffmpeg-streaming-68fb7e260bcd9ecd666dded95bb19db8c2898388.tar.gz |
lavfi/concat: fix silence duration computation.
Inside send_silence(), delta_ts was used inconsistently:
sometimes as the new value, sometimes as the old value.
Consistently use it as the new value, and add an argument
to know the last segment duration.
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/avf_concat.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index 7b5d591..733a124 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -232,7 +232,7 @@ static void close_input(AVFilterContext *ctx, unsigned in_no) ctx->input_pads[in_no].name, cat->nb_in_active); } -static void find_next_delta_ts(AVFilterContext *ctx) +static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta) { ConcatContext *cat = ctx->priv; unsigned i = cat->cur_idx; @@ -243,13 +243,15 @@ static void find_next_delta_ts(AVFilterContext *ctx) for (; i < imax; i++) pts = FFMAX(pts, cat->in[i].pts); cat->delta_ts += pts; + *seg_delta = pts; } -static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no) +static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no, + int64_t seg_delta) { ConcatContext *cat = ctx->priv; AVFilterLink *outlink = ctx->outputs[out_no]; - int64_t base_pts = cat->in[in_no].pts + cat->delta_ts; + int64_t base_pts = cat->in[in_no].pts + cat->delta_ts - seg_delta; int64_t nb_samples, sent = 0; int frame_nb_samples, ret; AVRational rate_tb = { 1, ctx->inputs[in_no]->sample_rate }; @@ -258,7 +260,7 @@ static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no) if (!rate_tb.den) return AVERROR_BUG; - nb_samples = av_rescale_q(cat->delta_ts - base_pts, + nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts, outlink->time_base, rate_tb); frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */ while (nb_samples) { @@ -283,8 +285,9 @@ static int flush_segment(AVFilterContext *ctx) int ret; ConcatContext *cat = ctx->priv; unsigned str, str_max; + int64_t seg_delta; - find_next_delta_ts(ctx); + find_next_delta_ts(ctx, &seg_delta); cat->cur_idx += ctx->nb_outputs; cat->nb_in_active = ctx->nb_outputs; av_log(ctx, AV_LOG_VERBOSE, "Segment finished at pts=%"PRId64"\n", @@ -295,7 +298,8 @@ static int flush_segment(AVFilterContext *ctx) str = cat->nb_streams[AVMEDIA_TYPE_VIDEO]; str_max = str + cat->nb_streams[AVMEDIA_TYPE_AUDIO]; for (; str < str_max; str++) { - ret = send_silence(ctx, cat->cur_idx - ctx->nb_outputs + str, str); + ret = send_silence(ctx, cat->cur_idx - ctx->nb_outputs + str, str, + seg_delta); if (ret < 0) return ret; } |