[FFmpeg-devel] [PATCH] avfilter/vf_delogo: add auto set the area inside of the frame
Liu Steven
lq at chinaffmpeg.org
Tue Sep 3 14:04:37 EEST 2019
> 在 2019年9月3日,下午3:24,Paul B Mahol <onemda at gmail.com> 写道:
>
> On 9/2/19, Steven Liu <lq at chinaffmpeg.org> wrote:
>> when the area outside of the frame, then use expr should
>> give user warning message and auto set to the area inside of the frame.
>>
>> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
>> ---
>> libavfilter/vf_delogo.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>>
>> diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
>> index 814575a36c..5521a29214 100644
>> --- a/libavfilter/vf_delogo.c
>> +++ b/libavfilter/vf_delogo.c
>> @@ -327,6 +327,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
>> *in)
>> s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
>> s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
>>
>> + if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) >
>> inlink->w ||
>> + s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) >
>> inlink->h) {
>> + av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
>> + "auto set the area inside of the frame\n");
>> + }
>> + if (s->x + (s->band - 1) < 0)
>> + s->x = s->band;
>> + if (s->y + (s->band - 1) < 0)
>> + s->y = s->band;
>> + if (s->x + s->w - (s->band*2 - 2) > inlink->w)
>> + s->x = inlink->w - s->w + (s->band*2 - 2);
>> + if (s->y + s->h - (s->band*2 - 2) > inlink->h)
>> + s->y = inlink->h - s->h + (s->band*2 - 2);
>> +
>
> What about s->h and s->w being too big?
dou you mean this test case?
localhost:dash StevenLiu$ ./ffmpeg -f lavfi -i testsrc2=s=1280x720 -filter_complex "delogo=x=(20*t):y=(20*t):w=(20000000*t):h=(300000000*t)" -y output.mp4
ffmpeg version N-94769-g4ae6031b20 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --enable-libass --enable-opengl --enable-libx264 --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local --enable-libtesseract --enable-libspeex --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox --enable-libxml2 --enable-librsvg --enable-libvmaf --enable-version3 --disable-stripping --disable-optimizations --enable-libvmaf
libavutil 56. 34.100 / 56. 34.100
libavcodec 58. 56.101 / 58. 56.101
libavformat 58. 32.104 / 58. 32.104
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.102 / 7. 58.102
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, lavfi, from 'testsrc2=s=1280x720':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 (rawvideo) -> delogo
delogo -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[delogo @ 0x7fd078d48340] Logo area is outside of the frame.
[Parsed_delogo_0 @ 0x7fd078d47a40] Failed to configure input pad on Parsed_delogo_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
localhost:dash StevenLiu$
>
>
>> ret = config_input(inlink);
>> if (ret < 0) {
>> av_frame_free(&in);
>> --
>> 2.15.1
>>
>>
>>
>> _______________________________________________
>> 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".
More information about the ffmpeg-devel
mailing list