Zend certified PHP/Magento developer

How to use ffmpeg to convert nv12 to bgra with hwaccel on intel GPU

I am new to video processing and recently started working on capturing camera content from rtsp h265 15fps 800×448 2000kbps and projecting it to /dev/fb0 device.

I use ffmpeg 4.4.2 on ubuntu 22.04 with intel elkhartlake Gen11,connected to display using HDMI

when I run following cmd

ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -hwaccel vaapi -loglevel verbose -rtsp_transport tcp -stimeout 30000000  -i rtsp://192.168.0.21/media.smp -pix_fmt bgra -f fbdev /dev/fb0

it consumed 13% cpu and 1.5% GPU (from sudo intel_gpu_top)

I know most of the ffmpeg cpu usage is consumed by “-pix_fmt bgra” because when I run

ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -hwaccel vaapi -loglevel verbose -rtsp_transport tcp -stimeout 30000000  -i rtsp://192.168.0.21/2x2/media.smp  -f null -

the CPU is only 3%-5%,GPU 1.5% , I guess the GPU is used for decoding

if I remove “pix_fmt bgra” from first command then ffmpeg quit with error saying

[fbdev @ 0x55e70d6cc800] Pixel format nv12 is not supported, use bgra
av_interleaved_write_frame(): Invalid argument

I guess the cpu is busy on converting from nv12 to bgra

so the question is , how can I project content to fb0 with less CPU ? and move those activities to GPU ? do I use scale_vaapi or something ?

I did search for fbset to support nv12 but not really sure how , all based on assumption that if I can get fb0 support nv12 then I can remove “-pix_fmt bgra” to reduce CPU usage

I also tried with “perf record” and seems the CPU was used by swscale filter

or ,suppose I use vpp_qsv filter ,does it mean I cannot convert format to bgra? because of this function here ,since it does not have bgra
https://github.com/FFmpeg/FFmpeg/blob/6d31619af2826adfe5aa71990cebafa8cbd6ecde/libavfilter/vf_vpp_qsv.c#L720

thanks