[FFmpeg-devel] [PATCH v1] avfilter/src_movie: Fix the loop function of dynamic logo
Limin Wang
lance.lmwang at gmail.com
Wed Apr 8 16:58:03 EEST 2020
ping this patch for review.
On Tue, Mar 17, 2020 at 06:55:00PM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
>
> The following command will attempt to create the input and overlay test sequence for you.
> ./ffmpeg -f lavfi -i color=white:duration=100:r=25:size=1280x720 input.mkv
> ./ffmpeg -f lavfi -i "testsrc=duration=5:size=320x240:rate=25" overlay.mkv
>
> Please try with below command and compare the final output.
> ./ffmpeg -y -filter_complex "movie=./input.mkv,setpts=PTS-STARTPTS[main];movie=./overlay.mkv:loop=5,setpts=PTS-STARTPTS[overlay];[main][overlay]overlay=10:10:
> enable='between(t,0,25)" test.mkv
>
> Without the patch applied, the overlay will repeat the last frame in overlay.mkv after the first loop.
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavfilter/src_movie.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> index 79423a8..2327046 100644
> --- a/libavfilter/src_movie.c
> +++ b/libavfilter/src_movie.c
> @@ -68,6 +68,8 @@ typedef struct MovieContext {
> int loop_count;
> int64_t discontinuity_threshold;
> int64_t ts_offset;
> + int64_t last_pts;
> + int64_t last_loop_pts;
>
> AVFormatContext *format_ctx;
> int eof;
> @@ -455,6 +457,7 @@ static int rewind_file(AVFilterContext *ctx)
> movie->st[i].done = 0;
> }
> movie->eof = 0;
> + movie->last_loop_pts = movie->last_pts;
> return 0;
> }
>
> @@ -565,6 +568,8 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
> if (frame->pts != AV_NOPTS_VALUE) {
> if (movie->ts_offset)
> frame->pts += av_rescale_q_rnd(movie->ts_offset, AV_TIME_BASE_Q, outlink->time_base, AV_ROUND_UP);
> + if (movie->last_loop_pts)
> + frame->pts += movie->last_loop_pts;
> if (st->discontinuity_threshold) {
> if (st->last_pts != AV_NOPTS_VALUE) {
> int64_t diff = frame->pts - st->last_pts;
> @@ -575,6 +580,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
> }
> }
> }
> + movie->last_pts =
> st->last_pts = frame->pts;
> }
> ff_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name,
> --
> 2.9.5
>
--
Thanks,
Limin Wang
More information about the ffmpeg-devel
mailing list