I am trying to work out how to do video encoding/decoding with ffmpeg making use the VPU.
Using Radxa’s Debian 12 image (b3) it has cix-ffmpeg installed.
$ dpkg -l | grep cix-ffmpeg
ii cix-ffmpeg 1.0.0 arm64 cix-ffmpeg package
From what I can tell the encoder and decoder are interfaced via v4l2m2m.
$ ffmpeg -hide_banner -encoders | grep v4l2
DSP API version: DSP Wrapper Build On Jan 7 2025 22:06:04 eb4a506
V..... h263_v4l2m2m V4L2 mem2mem H.263 encoder wrapper (codec h263)
V..... h264_v4l2m2m V4L2 mem2mem H.264 encoder wrapper (codec h264)
V..... hevc_v4l2m2m V4L2 mem2mem HEVC encoder wrapper (codec hevc)
V..... mpeg4_v4l2m2m V4L2 mem2mem MPEG4 encoder wrapper (codec mpeg4)
V..... vp8_v4l2m2m V4L2 mem2mem VP8 encoder wrapper (codec vp8)
$ ffmpeg -hide_banner -decoders | grep v4l2
DSP API version: DSP Wrapper Build On Jan 7 2025 22:06:04 eb4a506
V..... h263_v4l2m2m V4L2 mem2mem H.263 decoder wrapper (codec h263)
V..... h264_v4l2m2m V4L2 mem2mem H.264 decoder wrapper (codec h264)
V..... hevc_v4l2m2m V4L2 mem2mem HEVC decoder wrapper (codec hevc)
V..... mpeg1_v4l2m2m V4L2 mem2mem MPEG1 decoder wrapper (codec mpeg1video)
V..... mpeg2_v4l2m2m V4L2 mem2mem MPEG2 decoder wrapper (codec mpeg2video)
V..... mpeg4_v4l2m2m V4L2 mem2mem MPEG4 decoder wrapper (codec mpeg4)
V..... vc1_v4l2m2m V4L2 mem2mem VC1 decoder wrapper (codec vc1)
V..... vp8_v4l2m2m V4L2 mem2mem VP8 decoder wrapper (codec vp8)
V..... vp9_v4l2m2m V4L2 mem2mem VP9 decoder wrapper (codec vp9
Which I think is on /dev/video3|4
$ v4l2-ctl --list-devices
...
Linlon Video device (platform:mvx):
/dev/video3
/dev/video4
...
Using ffmpegs software encoder libx264 I see around 30% CPU usage for the process under “top” for the following command.
ffmpeg -threads 2 -c:v:1 libx264 -re -stream_loop -1 -fflags +genpts -i frigate/debug/thief-house.mp4 -r 5 -vf fps=5,scale=1280:720 -threads 2 -f rawvideo -pix_fmt yuv420p out.yuv
Attempting to run the hardware accelerated encoder h264_v4l2m2m I still see 30% CPU usage in linux top, meaning is defaulted back to software/CPU processing.
ffmpeg -threads 2 -c:v:1 h264_v4l2m2m -re -stream_loop -1 -fflags +genpts -i frigate/debug/thief-house.mp4 -r 5 -vf fps=5,scale=1280:720 -threads 2 -f rawvideo -pix_fmt yuv420p out.yuv
So the question is how do we do video hardware encoding/decoding using the VPU?