Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Thierry Foucu <tfoucu@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_tpad: if there is no frame to clone return early
Date: Fri, 25 Feb 2022 13:07:11 -0800
Message-ID: <CACXFHsTyv5_DM+BgW4+WOLb05NJPmZ1P94k2dL53z3gvTpS6Fw@mail.gmail.com> (raw)
In-Reply-To: <CAPYw7P419AoKX+tTDEfYxUGQ+fbLJ8_ynT31qcfwOK_YfUs1FQ@mail.gmail.com>

On Thu, Feb 24, 2022 at 11:50 PM Paul B Mahol <onemda@gmail.com> wrote:

> On Thu, Feb 24, 2022 at 11:21 PM Thierry Foucu <tfoucu@gmail.com> wrote:
>
> > On Thu, Feb 24, 2022 at 2:19 PM Thierry Foucu <tfoucu@gmail.com> wrote:
> >
> > >
> > >
> > > On Thu, Feb 24, 2022 at 1:50 PM Paul B Mahol <onemda@gmail.com> wrote:
> > >
> > >> On Thu, Feb 24, 2022 at 10:36 PM Thierry Foucu <tfoucu@gmail.com>
> > wrote:
> > >>
> > >> > On Thu, Feb 24, 2022 at 1:28 PM Paul B Mahol <onemda@gmail.com>
> > wrote:
> > >> >
> > >> > > On Thu, Feb 24, 2022 at 10:12 PM Thierry Foucu <tfoucu@gmail.com>
> > >> wrote:
> > >> > >
> > >> > > > On Thu, Feb 24, 2022 at 12:30 PM Paul B Mahol <git@videolan.org
> >
> > >> > wrote:
> > >> > > >
> > >> > > > > ffmpeg | branch: master | Paul B Mahol <onemda@gmail.com> |
> Thu
> > >> Feb
> > >> > 24
> > >> > > > > 20:32:41 2022 +0100|
> [3715f2f8643695940582ce040b7a052cccfb9db2]
> > |
> > >> > > > > committer: Paul B Mahol
> > >> > > > >
> > >> > > > > avfilter/vf_tpad: if there is no frame to clone return early
> > >> > > > >
> > >> > > > > >
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3715f2f8643695940582ce040b7a052cccfb9db2
> > >> > > > > ---
> > >> > > > >
> > >> > > > >  libavfilter/vf_tpad.c | 5 +++++
> > >> > > > >  1 file changed, 5 insertions(+)
> > >> > > > >
> > >> > > > > diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
> > >> > > > > index e5acece1e4..120dbcb4d3 100644
> > >> > > > > --- a/libavfilter/vf_tpad.c
> > >> > > > > +++ b/libavfilter/vf_tpad.c
> > >> > > > > @@ -148,6 +148,11 @@ static int activate(AVFilterContext *ctx)
> > >> > > > >                                frame->data, frame->linesize,
> > >> > > > >                                0, 0, frame->width,
> > frame->height);
> > >> > > > >          } else if (s->stop_mode == 1) {
> > >> > > > > +            if (!s->cache_stop) {
> > >> > > > > +                s->pad_stop = 0;
> > >> > > > > +                ff_outlink_set_status(outlink, AVERROR_EOF,
> > >> s->pts);
> > >> > > > > +                return 0;
> > >> > > > > +            }
> > >> > > > >              frame = av_frame_clone(s->cache_stop);
> > >> > > > >              if (!frame)
> > >> > > > >                  return AVERROR(ENOMEM);
> > >> > > > >
> > >> > > > >
> > >> > > > The problem with this solution is that the tpad will then not do
> > >> what
> > >> > we
> > >> > > > are expecting, which is padding video track, and the output file
> > >> will
> > >> > not
> > >> > > > have the desired duration.
> > >> > > > Will it not be better to just output black frame (aka stop_mode
> ==
> > >> 0) ,
> > >> > > > something like that?
> > >> > > >
> > >> > >
> > >> > > I doubt that, clone is clone, there is no point in padding stream
> > that
> > >> > have
> > >> > > no frames at all.
> > >> > >
> > >> > >
> > >> > >
> > >> > The sample I forwarded to JB has video frames. The problem was that
> > >> there
> > >> > was a re-init of the filter chain after a resolution change and
> after
> > >> the
> > >> > re-init, there were no frames but got frames before the re-init.
> > >> > I will understand for a media file which has NEVER received a video
> > >> frame
> > >> > and in this case, this is the correct solution.
> > >> >
> > >>
> > >> Hmm, so you encode output with resolution change, why not use scale
> > filter
> > >> as first filter and then no resolution ever change for rest of graph?
> > >> Adding support for resolution changes to all filters is very time
> > >> consuming
> > >> task and I see no real benefit in doing that now.
> > >>
> > >
> > > We do have the scale filter in front of the tpad filter. Here is the
> > > filter chain we are using
> > >
> > >
> >
> idet=1.04:1.5,yadif=0:-1:1,scale=+528:+864:flags=bicubic,setsar=1,fps=fps=16.601,tpad=stop_mode=clone:stop_duration=2808ms
> > >
> >
>
> Is this just increasing size instead of setting constant one?
>

Nope. It will just scale the video to 528x864


>
>
> > > And it does crash.
> > >
> > > Even just fps=fps=16.601,tpad=stop_mode=clone:stop_duration=2808ms
> > > reproduce the problem.
> > >
> >
> > Maybe an option to the tpad filter to decide what should be the output
> when
> > the stop_mode == 1 and cache_stop is NULL?
> > So, in some cases, people may want a color frame, and some other will
> just
> > want to exit right away?
> >
>
> That is too much for a special option.
>

I understand.
I'm just worried that due to some re-init of the filter chain and the fact
there are filters which may or may not output a frame after the re-init,
the tpad filter will then have no cache frame to clone. And in this case,
the file does not have the length expected.

I guess if it is documented or av_log, people will be aware of the
potential issue.

Anyway, thanks a lot for the quick fix.


> >
> >
> > >
> > >
> > >>
> > >>
> > >> >
> > >> >
> > >> > > >
> > >> > > > iff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
> > >> > > > index e5acece1e4..5e4062e9f2 100644
> > >> > > > --- a/libavfilter/vf_tpad.c
> > >> > > > +++ b/libavfilter/vf_tpad.c
> > >> > > > @@ -140,7 +140,7 @@ static int activate(AVFilterContext *ctx)
> > >> > > >              ff_outlink_set_status(outlink, AVERROR_EOF,
> s->pts);
> > >> > > >              return 0;
> > >> > > >          }
> > >> > > > -        if (s->stop_mode == 0) {
> > >> > > > +        if (s->stop_mode == 0 || !s->cache_stop) {
> > >> > > >              frame = ff_get_video_buffer(outlink, outlink->w,
> > >> > > outlink->h);
> > >> > > >              if (!frame)
> > >> > > >                  return AVERROR(ENOMEM);
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > > _______________________________________________
> > >> > > > > ffmpeg-cvslog mailing list
> > >> > > > > ffmpeg-cvslog@ffmpeg.org
> > >> > > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
> > >> > > > >
> > >> > > > > To unsubscribe, visit link above, or email
> > >> > > > > ffmpeg-cvslog-request@ffmpeg.org with subject "unsubscribe".
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > > > --
> > >> > > >
> > >> > > > Thierry Foucu
> > >> > > > _______________________________________________
> > >> > > > ffmpeg-devel mailing list
> > >> > > > ffmpeg-devel@ffmpeg.org
> > >> > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >> > > >
> > >> > > > To unsubscribe, visit link above, or email
> > >> > > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > >> > > >
> > >> > > _______________________________________________
> > >> > > ffmpeg-devel mailing list
> > >> > > ffmpeg-devel@ffmpeg.org
> > >> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >> > >
> > >> > > To unsubscribe, visit link above, or email
> > >> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > >> > >
> > >> >
> > >> >
> > >> > --
> > >> >
> > >> > Thierry Foucu
> > >> > _______________________________________________
> > >> > ffmpeg-devel mailing list
> > >> > ffmpeg-devel@ffmpeg.org
> > >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >> >
> > >> > To unsubscribe, visit link above, or email
> > >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > >> >
> > >> _______________________________________________
> > >> ffmpeg-devel mailing list
> > >> ffmpeg-devel@ffmpeg.org
> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >>
> > >> To unsubscribe, visit link above, or email
> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > >>
> > >
> > >
> > > --
> > >
> > > Thierry Foucu
> > >
> >
> >
> > --
> >
> > Thierry Foucu
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>


-- 

Thierry Foucu
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-02-25 21:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220224203039.CD4BB41059B@natalya.videolan.org>
2022-02-24 21:11 ` Thierry Foucu
2022-02-24 21:29   ` Paul B Mahol
2022-02-24 21:35     ` Thierry Foucu
2022-02-24 21:51       ` Paul B Mahol
2022-02-24 22:19         ` Thierry Foucu
2022-02-24 22:20           ` Thierry Foucu
2022-02-25  7:51             ` Paul B Mahol
2022-02-25 21:07               ` Thierry Foucu [this message]
2022-02-27 11:55                 ` Paul B Mahol
2022-02-28 17:52                   ` Thierry Foucu
2022-03-03 12:40                     ` Paul B Mahol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACXFHsTyv5_DM+BgW4+WOLb05NJPmZ1P94k2dL53z3gvTpS6Fw@mail.gmail.com \
    --to=tfoucu@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git