[FFmpeg-devel] [PATCH] lavfi: add lumakey_opencl filter

Mark Thompson sw at jkqxz.net
Sun Aug 5 01:50:02 EEST 2018


On 25/07/18 13:13, Danil Iashchenko wrote:
> Add lumakey_opencl filter. Behaves like existing lumakey filter.
> 
> ---
>  configure                       |   1 +
>  libavfilter/Makefile            |   2 +
>  libavfilter/allfilters.c        |   1 +
>  libavfilter/opencl/lumakey.cl   |  43 +++++++
>  libavfilter/opencl_source.h     |   1 +
>  libavfilter/vf_lumakey_opencl.c | 243 ++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 291 insertions(+)
>  create mode 100644 libavfilter/opencl/lumakey.cl
>  create mode 100644 libavfilter/vf_lumakey_opencl.c


I think you need a bit more configuration to make this work without needing to force the formats externally.  I guess you did something like 'format=yuv420p,hwupload,lumakey_opencl,hwdownload,format=yuva420p'?

It should probably be able to work with something like:

./ffmpeg_g -y -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device opencl=cl at va -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device va -i in1.mp4 -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device va -i in2.mp4 -an -filter_hw_device cl -filter_complex '[0:v]scale_vaapi=format=yuv420p,hwmap,lumakey_opencl[a]; [1:v]scale_vaapi=format=yuv420p,hwmap[b]; [a][b]overlay_opencl,hwmap=derive_device=vaapi:reverse=1,scale_vaapi=format=nv12' -c:v h264_vaapi out.mp4

to composite two videos together keyed by the luma of the first (I'm not sure that command-line is exactly right, but something like that).  In this case there isn't any way to make the output format implicitly do the right thing, so the filter needs to deal with the formats internally.  (And extra points if you can avoid the yuv420p conversion :)


Everything else in the patch looks fine.

Thanks,

- Mark


More information about the ffmpeg-devel mailing list