From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0FC6F42204 for ; Mon, 28 Feb 2022 17:53:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 54E7E68AED0; Mon, 28 Feb 2022 19:52:59 +0200 (EET) Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 871A868AE64 for ; Mon, 28 Feb 2022 19:52:53 +0200 (EET) Received: by mail-vs1-f49.google.com with SMTP id e26so13844393vso.3 for ; Mon, 28 Feb 2022 09:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=leuyOkQi57Nn2hdjQiPvtZrKeL1goquLySnFFV6adSc=; b=ThG2P3iuz9asMOiWn4tHAofzpJ0S7DX7X/HxZ6NAc2OoF1tiEIIGVfLyY+gdf1aVAu pXvdFX6bcGifoYTa2j7u59G7K0qjkKhUR/ibSG1Ujlt+/r4Y2Pedvb7CU8WQi4rN+zr+ FjUUn74V/Q8SM5hY+b8D8JdvGFHNUnqiEVsabv0jM+HM6uiXXK5QPDoQNjmH58+ZQoEZ PAi+w+rVm6vmSWSBJMpSuy24xRCwy/VCKM8Cq4MG3Mc1o+2vB/rX9NAxZaMchb0o72M8 /7DG4tVG8hoF0vPulUyBJ046f5X31UfYcFcuPKt0T7XUCrE+08/mi+VhG/Yx+zdVq9ym gXAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=leuyOkQi57Nn2hdjQiPvtZrKeL1goquLySnFFV6adSc=; b=OjgAY8YVnBx61vp8ZvqHmY6F9ouTcW+NsFPmbvxh8PubtaVuNnrpjYhyZZl0joyu1U f4POZ911CVXTuyujvJdk+0KdsCGyWCzWBYWId/WC7PWQAqjcHUrbt+Z7XKrqNw8OxgTE 1fMx3QAYobCmcza9BsQFtKQHmy6un0O/XQA7W932oEigG1zJdoLvUQxgXcLX85rSbsfy H8MNok0QiPv4gv1Gc08XkI8MeJODCSYSzPHYGqnNLt5Yx9BniNnUTbGblZUQdDzfBwkR x/Y+3/5Ej2jLTN1vG7JRrrqAkzViQfoSWikKkbGggAo1TUQ7S5UaK0iOVC8nWEkiVw5j vKnQ== X-Gm-Message-State: AOAM532ZGirD31XcQeD/u2b439RFAxQ5nbXjvgJTA0Dc+ap+Ke4O9Co9 qFUkmZSJcCf0qrsolovNSldQUpYJuC8Pth89QjV4UL5eILo= X-Google-Smtp-Source: ABdhPJwI3TSVPaR1egYJXm/9Fch8/9fUhvUieCblv3FThhxGDCdDp45qBs53bWHOdMlznUn1L9HqIAuVgZOO+INUqPs= X-Received: by 2002:a05:6102:3e8f:b0:31b:74e8:88bd with SMTP id m15-20020a0561023e8f00b0031b74e888bdmr8259284vsv.52.1646070771459; Mon, 28 Feb 2022 09:52:51 -0800 (PST) MIME-Version: 1.0 References: <20220224203039.CD4BB41059B@natalya.videolan.org> In-Reply-To: From: Thierry Foucu Date: Mon, 28 Feb 2022 09:52:14 -0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_tpad: if there is no frame to clone return early X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, Feb 27, 2022 at 3:54 AM Paul B Mahol wrote: > On Fri, Feb 25, 2022 at 10:08 PM Thierry Foucu wrote: > > > On Thu, Feb 24, 2022 at 11:50 PM Paul B Mahol wrote: > > > > > On Thu, Feb 24, 2022 at 11:21 PM Thierry Foucu > wrote: > > > > > > > On Thu, Feb 24, 2022 at 2:19 PM Thierry Foucu > > wrote: > > > > > > > > > > > > > > > > > > > On Thu, Feb 24, 2022 at 1:50 PM Paul B Mahol > > wrote: > > > > > > > > > >> On Thu, Feb 24, 2022 at 10:36 PM Thierry Foucu > > > > wrote: > > > > >> > > > > >> > On Thu, Feb 24, 2022 at 1:28 PM Paul B Mahol > > > > 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 > | > > > 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 > > > > Then why filter is still reinited then? > Looks like serious bug to me. > Here is the verbose log when running ffmpeg with the filter chain. The input resolution went from 1280x692 then changed to 1280x720 followed by 1280x718 And from the log, it is clear that the filter chain is being re-initialize. Input #0, matroska,webm, from '/tmp/crash_tpad': Metadata: ENCODER : Lavf58.76.100 Duration: 00:08:07.44, start: 0.000000, bitrate: 78 kb/s Stream #0:0(eng): Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv), 1280x692, SAR 1:1 DAR 320:173, 59.94 fps, 59.94 tbr, 1k tbn (default) Metadata: ALPHA_MODE : 1 DURATION : 00:08:06.780000000 Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default) Metadata: DURATION : 00:08:07.440000000 Stream mapping: Stream #0:0 -> #0:0 (vp9 (native) -> wrapped_avframe (native)) Stream #0:1 -> #0:1 (opus (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help [graph_1_in_0_1 @ 0x55df4ff5f180] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x4 [format_out_0_1 @ 0x55df4ff5fd40] auto-inserting filter 'auto_aresample_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1' [auto_aresample_0 @ 0x55df4ff61340] ch:1 chl:mono fmt:fltp r:48000Hz -> ch:1 chl:mono fmt:s16 r:48000Hz [Parsed_scale_2 @ 0x55df4ffa7040] w:+528 h:+864 flags:'bicubic' interl:0 [graph 0 input from stream 0:0 @ 0x55df4ffab580] w:1280 h:692 pixfmt:yuv420p tb:1/1000 fr:19001/317 sar:1/1 [Parsed_scale_2 @ 0x55df4ffa7040] w:1280 h:692 fmt:yuv420p sar:1/1 -> w:528 h:864 fmt:yuv420p sar:5760/1903 flags:0x4 [Parsed_setsar_3 @ 0x55df4ffa7e80] w:528 h:864 sar:5760/1903 dar:320/173 -> sar:1/1 dar:11/18 [Parsed_fps_4 @ 0x55df4ffa8880] fps=16601/1000 [Parsed_fps_4 @ 0x55df4ffa8880] Set first pts to 0 Output #0, null, to 'pipe:': Metadata: encoder : Lavf59.17.102 Stream #0:0(eng): Video: wrapped_avframe, 1 reference frame, yuv420p(tv, progressive), 528x864 (0x0) [SAR 1:1 DAR 11:18], q=2-31, 200 kb/s, 16.60 fps, 16.60 tbn (default) Metadata: ALPHA_MODE : 1 DURATION : 00:08:06.780000000 encoder : Lavc59.21.100 wrapped_avframe Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s (default) Metadata: DURATION : 00:08:07.440000000 encoder : Lavc59.21.100 pcm_s16le [Parsed_idet_0 @ 0x55df4ffa0700] Repeated Fields: Neither: 88 Top: 0 Bottom: 0 [Parsed_idet_0 @ 0x55df4ffa0700] Single frame detection: TFF: 0 BFF: 0 Progressive: 1 Undetermined: 87 [Parsed_idet_0 @ 0x55df4ffa0700] Multi frame detection: TFF: 0 BFF: 0 Progressive: 1 Undetermined: 87 [Parsed_fps_4 @ 0x55df4ffa8880] 87 frames in, 62 frames out; 27 frames dropped, 2 frames duplicated. [Parsed_scale_2 @ 0x55df4ffaa1c0] w:+528 h:+864 flags:'bicubic' interl:0 [graph 0 input from stream 0:0 @ 0x55df4ff94140] w:1280 h:720 pixfmt:yuv420p tb:1/1000 fr:19001/317 sar:1/1 [scaler_out_0_0 @ 0x55df4ff9de00] w:528 h:864 flags:'' interl:0 [Parsed_scale_2 @ 0x55df4ffaa1c0] w:1280 h:720 fmt:yuv420p sar:1/1 -> w:528 h:864 fmt:yuv420p sar:32/11 flags:0x4 [Parsed_setsar_3 @ 0x55df4ffaea40] w:528 h:864 sar:32/11 dar:16/9 -> sar:1/1 dar:11/18 [Parsed_fps_4 @ 0x55df4ff91fc0] fps=16601/1000 [scaler_out_0_0 @ 0x55df4ff9de00] w:528 h:864 fmt:yuv420p sar:1/1 -> w:528 h:864 fmt:yuv420p sar:1/1 flags:0x0 [Parsed_fps_4 @ 0x55df4ff91fc0] Set first pts to 64 [Parsed_idet_0 @ 0x55df4ff9bd00] Repeated Fields: Neither: 998 Top: 0 Bottom: 2 [Parsed_idet_0 @ 0x55df4ff9bd00] Single frame detection: TFF: 0 BFF: 0 Progressive: 11 Undetermined: 989 [Parsed_idet_0 @ 0x55df4ff9bd00] Multi frame detection: TFF: 0 BFF: 0 Progressive: 1000 Undetermined: 0 [Parsed_fps_4 @ 0x55df4ff91fc0] 999 frames in, 8004 frames out; 39 frames dropped, 7044 frames duplicated. [Parsed_scale_2 @ 0x55df50130e80] w:+528 h:+864 flags:'bicubic' interl:0 [graph 0 input from stream 0:0 @ 0x55df5029dd00] w:1280 h:718 pixfmt:yuv420p tb:1/1000 fr:19001/317 sar:1/1 [scaler_out_0_0 @ 0x55df4ff93640] w:528 h:864 flags:'' interl:0 [Parsed_scale_2 @ 0x55df50130e80] w:1280 h:718 fmt:yuv420p sar:1/1 -> w:528 h:864 fmt:yuv420p sar:11520/3949 flags:0x4 [Parsed_setsar_3 @ 0x55df50413380] w:528 h:864 sar:11520/3949 dar:640/359 -> sar:1/1 dar:11/18 [Parsed_fps_4 @ 0x55df4ff7af80] fps=16601/1000 [scaler_out_0_0 @ 0x55df4ff93640] w:528 h:864 fmt:yuv420p sar:1/1 -> w:528 h:864 fmt:yuv420p sar:1/1 flags:0x0 [Parsed_fps_4 @ 0x55df4ff7af80] Set first pts to 8081 No more output streams to write to, finishing. frame= 8066 fps=1787 q=-0.0 Lsize=N/A time=00:08:07.44 bitrate=N/A speed= 108x video:3529kB audio:45698kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Input file #0 (/tmp/crash_tpad): Input stream #0:0 (video): 1091 packets read (1667477 bytes); 1091 frames decoded; Input stream #0:1 (audio): 8124 packets read (3026650 bytes); 8124 frames decoded (23397120 samples); Total: 9215 packets (4694127 bytes) demuxed Output file #0 (pipe:): Output stream #0:0 (video): 8066 frames encoded; 8066 packets muxed (3613568 bytes); Output stream #0:1 (audio): 8124 frames encoded (23397120 samples); 8124 packets muxed (46794240 bytes); Total: 16190 packets (50407808 bytes) muxed [Parsed_idet_0 @ 0x55df4ff7f8c0] Repeated Fields: Neither: 1 Top: 0 Bottom: 0 [Parsed_idet_0 @ 0x55df4ff7f8c0] Single frame detection: TFF: 0 BFF: 0 Progressive: 0 Undetermined: 1 [Parsed_idet_0 @ 0x55df4ff7f8c0] Multi frame detection: TFF: 0 BFF: 0 Progressive: 0 Undetermined: 1 [Parsed_fps_4 @ 0x55df4ff7af80] 1 frames in, 0 frames out; 1 frames dropped, 0 frames duplicated. [AVIOContext @ 0x55df4fe98180] Statistics: 4759868 bytes read, 0 seeks > > > > > > > > > > > > > > > > > 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". > > > _______________________________________________ > 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".