From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 3504E4A175 for <ffmpegdev@gitmailbox.com>; Mon, 24 Mar 2025 16:20:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01DF4687BE2; Mon, 24 Mar 2025 18:20:11 +0200 (EET) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9F43687B25 for <ffmpeg-devel@ffmpeg.org>; Mon, 24 Mar 2025 18:20:04 +0200 (EET) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3913fdd0120so2519158f8f.0 for <ffmpeg-devel@ffmpeg.org>; Mon, 24 Mar 2025 09:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742833204; x=1743438004; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=9oLEkiOGeeBz41+jdbQf5eJolM2kxvMpbKhqlaZkgQs=; b=S5Zr/BE27fSuE6Idux1y8Qh/e+2QcTk6t4VevwNZlu25m4w+XFvdelBlMKQVqtXVEb VHfqrkGpMui9DEWH1K6MZ9sJcTDD/QoRHI/+bE+FpUjTpsNreIJI7Mz4kvuVv6H38Kny xxYdrE4wUf7pG+YMV/WBh42R3fwYgsLCvQMOfaPv3/+7TG/AP+HfHs2qlnKuEcbuWiZ8 2JjxII/Fj8gxWKPLHmWk7RnFYSaCt7zzUncWRuwXihfpk70yX+qnUGREAu2VQOPJXG5N KjZRboCrs0oZ564S2PyjlUTqg2+V80UjrusLDoKt+0YeSvnO+RgLkfg0odD9+B20zf4D 80sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742833204; x=1743438004; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9oLEkiOGeeBz41+jdbQf5eJolM2kxvMpbKhqlaZkgQs=; b=O1BGv1YPRzPruB9oJhiKYjyKstyO/RnU1FBRZDHsM9jOhEHgsef8IaY33kmxVMaUKw wSDCKD9tHPMDYmxY5ldPRjq5NdiEmcDfB8RX0Q0uRI5wVUWHHQM9lwobY3ATr0H8lXKu RudEWy0rqUUULtjz8cWxsLCRciN5us3NCBrwqqfrKjaNubmORNk0gjDzhSURXhaMZjPf ZCc7WJcdZBASMsVVl0X5N1CDSTpaXufzW0Haqlt5qZ9WqYK1v6D0npYvJ+y+QkKdJuJe cyVFo5mmQy0HX9FFv/cy/iSV4EvIQzd8xclpgerz8QcXHyhH6E0e2DIg6bqiBnaWYd1e 2K8w== X-Gm-Message-State: AOJu0Yx62jt+2FGKHOsqm8VakaKSZUNRho14xndCiXK+v2Coq0PQmfdG hxHnLqIB9ZbWxH3NQLF47wekTUOj7Ub0CJLOZ3YhloDhFoY9jEjtRNI28snf X-Gm-Gg: ASbGncu/frvY15vA7WssenQWRHSw6/9cd2BEDZWa8qvPr3d1Q4A/bGlw7TzA/wNgux2 DWNLOMKThxdRrSInV15bCc+LyqWNcQVw/lh8nlx3Q+DJw+9qWqw7y+F0uPDwlT1PoOuDlz2zP9j CVkM5VnEVpoM8B0kaPujdQVZNr3aLe9n+Dkjb5WI1x7kurrmHOR8WI3DJLGBUERm/mZ8vsWStIt sReOgMUuVSnY2CLD7xavdGt20Um1LbvIR3QsGoNsEGRfvGk3o0nMLLCSBEasQo+WZ5iUZgJ0Wj8 YAmYr6XRf2H74lihgGxh9aSnro73/rLhut5cwn8gqMDcGAyAvl28LC+MmfajZ0PCPvpLNaVCyiZ 1/LJ9pmyZzYvBY+da1G+kDT8= X-Google-Smtp-Source: AGHT+IEOgAGxbAsAFYOFHAEOI0ee8y85hJ6qwppKFSW9vl8m0yB7jSVqDHJ9iAzQYgZ9qE23SgqgCw== X-Received: by 2002:a5d:6485:0:b0:391:2d8f:dd59 with SMTP id ffacd0b85a97d-3997f90d943mr11327843f8f.24.1742833203910; Mon, 24 Mar 2025 09:20:03 -0700 (PDT) Received: from ?IPV6:2001:9e8:1da6:4200:189b:8e2c:55b0:b44b? ([2001:9e8:1da6:4200:189b:8e2c:55b0:b44b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9957aasm11540804f8f.10.2025.03.24.09.20.03 for <ffmpeg-devel@ffmpeg.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Mar 2025 09:20:03 -0700 (PDT) Message-ID: <8bdfe841-080b-49f6-913b-7577d03a1214@gmail.com> Date: Mon, 24 Mar 2025 17:20:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Leandro Santiago <leandrosansilva@gmail.com> To: ffmpeg-devel@ffmpeg.org References: <6bef7ee3-6e0b-496a-9018-ce02d5e8cd63@gmail.com> <2477728b-6217-446a-9a15-830f028baea0@gmail.com> Content-Language: en-US In-Reply-To: <2477728b-6217-446a-9a15-830f028baea0@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: Proof of Concept: enable out-of-tree filters X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/8bdfe841-080b-49f6-913b-7577d03a1214@gmail.com/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> In this iteration I've made the following changes, based on the received feedback: - No external tools are needed by the build system. - The external filters should be put in ext/libavfilter. Anything there will be included. - The build system will execute a file called `configure.sh` in the directory of the external filter. This script has access to the functions and variables defined on `./configure`, as it's included via `.` on sh. - I will document the "API" for the external filters as soon the approach is approved, but an example of filter can be found at https://gitlab.com/leandrosansilva/ffmpeg-extra-filter-example . If you are unhappy with the example code hosted on gitlab.com, I can move it elsewhere where it gets easier for you to have access to the code. - Essentially, an external filter is composed by at least a `configure.sh` and a `Makefile`. I really hope this can be the last iteration, as I ran out of ideas on how to simplify the process, so please let me know your thoughts :-) Leandro On 3/24/25 16:56, Leandro Santiago wrote: > This is a POC/prototype that aims to enable out of tree filters on > FFmpeg. > > Here is how to test it, with an example filter: > > ``` > mkdir -p ext/libavfilter > pushd ext/libavfilter > git clone https://gitlab.com/leandrosansilva/ffmpeg-extra-filter-example example > popd > ``` > > Then compile ffmpeg as usual: > > ``` > ./configure && make && make install > ``` > > Now you can use the new filters: > > ``` > ffplay /path/to/file.webm -vf 'foo,bar' > ``` > > What works: > > - Building C based filters with no extra, or simple dependencies. > - Multiple filters in the same object file. > > What was not implemented: > > - I believe it would be useful to check if the license of the filter is > compatible with the license used to build FFmpeg. > > - Only extra filters written in C (maybe C++?) are supported for now. > One of my goals is to enable Rust as well. > > - Documentation > > - There should be a way to have optional dependencies, for filters that > can have multiple "backends", for instance, to be chosen at build time. > > Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com> > --- > .gitignore | 3 ++ > configure | 60 ++++++++++++++++++++++++++++++++++++++-- > libavfilter/Makefile | 4 +++ > libavfilter/allfilters.c | 1 + > 4 files changed, 66 insertions(+), 2 deletions(-) > > diff --git a/.gitignore b/.gitignore > index 430abaf91b..7d66dee516 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -44,3 +44,6 @@ > /tools/python/__pycache__/ > /libavcodec/vulkan/*.c > /libavfilter/vulkan/*.c > +/ffbuild/external-filters.mak > +/libavfilter/external_filters_extern.h > +/ext > diff --git a/configure b/configure > index 2fdbe8cbbe..317862fa1a 100755 > --- a/configure > +++ b/configure > @@ -1798,6 +1798,7 @@ AVDEVICE_COMPONENTS=" > > AVFILTER_COMPONENTS=" > filters > + external_filters > " > > AVFORMAT_COMPONENTS=" > @@ -4086,7 +4087,7 @@ swscale_deps="avutil" > swscale_suggest="libm stdatomic" > > avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs liblcevc_dec_extralibs lcms2_extralibs" > -avfilter_extralibs="pthreads_extralibs" > +avfilter_extralibs="pthreads_extralibs external_filters_extralibs" > avutil_extralibs="d3d11va_extralibs d3d12va_extralibs mediacodec_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vaapi_win32_extralibs vdpau_x11_extralibs" > > # programs > @@ -4324,10 +4325,15 @@ ALL_COMPONENTS=" > $AVFORMAT_COMPONENTS_LIST > " > > -for n in $COMPONENT_LIST; do > +enable_component() { > + n="$1" > v=$(toupper ${n%s})_LIST > eval enable \$$v > eval ${n}_if_any="\$$v" > +} > + > +for n in $COMPONENT_LIST; do > + enable_component "$n" > done > > enable $ARCH_EXT_LIST > @@ -7463,6 +7469,56 @@ elif enabled iconv; then > check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv > fi > > +# Handle external filters from the directory ext/libavfilter > + > +echo "" > libavfilter/external_filters_extern.h > +echo "" > ffbuild/external-filters.mak > + > +EXTERNAL_FILTER_LIST="" > + > +# This function is used by the external filters' configure.sh script to register the filters > +register_external_filter_symbol() { > + EXT_FILTER_SYMBOL="$1" > + EXTERNAL_FILTER_LIST="$EXTERNAL_FILTER_LIST $(echo $EXT_FILTER_SYMBOL | sed 's/^ff_[avfsinkrc]\{2,5\}_\([[:alnum:]_]\{1,\}\)/\1_filter/')" > + > + eval "$(echo "$EXT_FILTER_SYMBOL" | sed 's/^ff_\([avfsinkrc]\{2,5\}\)_\([[:alnum:]]\{1,\}\)$/full_filter_name_\2=\1_\2/')" > + > + echo "extern const FFFilter $EXT_FILTER_SYMBOL;" >> libavfilter/external_filters_extern.h > + > + echo "EXTERNAL_FILTER_$(\ > + echo $EXT_FILTER_SYMBOL \ > + | sed 's/^ff_[avfsinkrc]\{2,5\}_\([[:alnum:]]\{1,\}\)$/\1/' \ > + | tr a-z A-Z \ > + )_LOCATION = $CURRENT_EXT_FILTER_LOCATION" >> ffbuild/external-filters.mak > +} > + > +if [ -d "ext/libavfilter" ]; then > + for f in ext/libavfilter/*; do > + [ -f "$f/configure.sh" ] || die "Mandatory file $f/configure.sh not found" > + [ -f "$f/Makefile" ] || die "Mandatory file $f/Makefile not found" > + CURRENT_EXT_FILTER_LOCATION="$f" > + . "$f/configure.sh" || die "Could not configure external filter at $f" > + echo "include $f/Makefile" >> ffbuild/external-filters.mak > + done > + > + enable_component external_filters > +fi > + > +FILTER_LIST=" > + $FILTER_LIST > + $EXTERNAL_FILTER_LIST > +" > + > +AVFILTER_COMPONENTS_LIST=" > + $AVFILTER_COMPONENTS_LIST > + $EXTERNAL_FILTER_LIST > +" > + > +ALL_COMPONENTS=" > + $ALL_COMPONENTS > + $EXTERNAL_FILTER_LIST > +" > + > enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel" > > # add some useful compiler flags if supported > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 7c0d879ec9..877b24c30f 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -27,6 +27,10 @@ OBJS = allfilters.o \ > include $(SRC_PATH)/libavfilter/dnn/Makefile > include $(SRC_PATH)/libavfilter/vulkan/Makefile > > +# external filters handling > +include $(SRC_PATH)/ffbuild/external-filters.mak > +EXTERNAL_FILTER_FLAGS = -I$(PWD) -I$(PWD)/libavfilter > + > OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o > OBJS-$(HAVE_THREADS) += pthread.o > > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 740d9ab265..c2d576e4be 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -621,6 +621,7 @@ extern const FFFilter ff_vsrc_buffer; > extern const FFFilter ff_asink_abuffer; > extern const FFFilter ff_vsink_buffer; > > +#include "libavfilter/external_filters_extern.h" > #include "libavfilter/filter_list.c" > > _______________________________________________ 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".