[FFmpeg-devel] [PATCH v1] avfilter/src_movie: Fix the loop function of dynamic logo
Marton Balint
cus at passwd.hu
Wed May 6 22:43:32 EEST 2020
On Tue, 5 May 2020, lance.lmwang at gmail.com wrote:
> On Mon, May 04, 2020 at 09:34:02PM +0200, Marton Balint wrote:
>>
>>
>> On Mon, 4 May 2020, lance.lmwang at gmail.com wrote:
>>
>> > On Sun, May 03, 2020 at 07:10:07PM +0200, Marton Balint wrote:
>> > >
>> > >
>> > > On Sun, 3 May 2020, lance.lmwang at gmail.com wrote:
>> > >
>> > > > 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.
>> > >
>> > > Why?
>> >
>> > I haven't clear about the question yet, if you try to insert a dynamic logo
>> > repeatly, without the patch, the dynamic logo will not overlay repeatly.
>>
>> But why is that? You explained what this patch fixes. But you have not
>> explained why the error is happening and what goes wrong in the current
>> code. I am asking, because there is some timestamp discontinuity handling in
>> src_movie, shouldn't that handle the timestamp discontinuity caused by
>> looping?
>
> When the dynamic logo is end for reading, the pts will not accumulate with the
> first loop, so it'll failed to overlay.
That is intentional, that is how the src_movie works. It passes on source
pts values by default. If you want discontinuty handling to kick in either
for seeking or looping, you should use the discontinuity option.
E.g:
./ffmpeg -y -filter_complex
"movie=./input.mkv[main];movie=./overlay.mkv:loop=5:discontinuity=0.04[overlay];[main][overlay]overlay=10:10:enable='between(t,0,25)"
test.mkv
So this patch is wrong I am afraid.
Regards,
Marton
>
>>
>> Thanks,
>> Marton
>>
>> > >
>> > >
>> > > Thanks,
>> > > Marton
>> > >
>> > > > > > > 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
>> > > > > > > ping
>> > > > > -- > Thanks,
>> > > > Limin Wang
>> > > > _______________________________________________
>> > > > ffmpeg-devel mailing list
>> > > > ffmpeg-devel at ffmpeg.org
>> > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> > > > > To unsubscribe, visit link above, or email
>> > > > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>> > > _______________________________________________
>> > > ffmpeg-devel mailing list
>> > > ffmpeg-devel at ffmpeg.org
>> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> > >
>> > > To unsubscribe, visit link above, or email
>> > > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>> >
>> > --
>> > Thanks,
>> > Limin Wang
>> > _______________________________________________
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel at ffmpeg.org
>> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> > To unsubscribe, visit link above, or email
>> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
> --
> Thanks,
> Limin Wang
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list