schunckt Posted yesterday at 07:02 AM Posted yesterday at 07:02 AM Hi all, I'm still working on video hwaccel with some progress. Can anyone provide a confirmed working ffmpeg command line for camera capture and hardware encoding? I dont care about the platform, either rockchip or anything else, no matter about kernel or arbiam version. Using v4l2request is the only requirement. I'm using either 7.1.1 with libreelec patches or @Kwiboo's fork. I know there are a bunch of threads here and elswhere in the web but most are outdated, dealing with vaapi or other stuff, but I want to stay on v4l2 which seems to be the future. Thanks! T. 0 Quote
usual user Posted yesterday at 07:33 AM Posted yesterday at 07:33 AM 30 minutes ago, schunckt said: I know there are a bunch of threads here and elswhere in the web but most are outdated, dealing with vaapi or other stuff, but I want to stay on v4l2 which seems to be the future. https://lore.kernel.org/linux-media/Z4e9wNxZjvnytXlL@pengutronix.de/ 0 Quote
schunckt Posted yesterday at 09:12 AM Author Posted yesterday at 09:12 AM Thanks but THIS is the question Can anyone provide a confirmed working ffmpeg command line for camera capture and hardware encoding? T. 0 Quote
schunckt Posted 4 hours ago Author Posted 4 hours ago Hi again! I'd also like to get the mediactl output of a working encoder/decoder (maybe rockchip) media-ctl -d 0 -p of course device # could be diferent .... Thanks! T. 0 Quote
eselarm Posted 3 hours ago Posted 3 hours ago My understanding is that v4l2request is for vendor kernel that does RKMPP, so that V4L2 API is available for browser or mpv to play video, so decoding only. I have not focused on that, although HEVC HW accelerated decoding would be really welcome. W.r.t. camera capture and encoding, I only used RPI1 (legacy firmware V4L2 stack) and RPi3/4 (libcamera). Many variants, but is it possible to get uncompressed frames from a camera, push it through the h264 HW encoder (h264_v4l2m2m) and then to some RTSP sink (MediaMTX) to show it as WebRTC in a browser. That is with RPi kernel and RPi ffmpeg, so 'vendor' solution. Although V4L2, it won't work with a standard/mainline Debian kernel yet AFAIK. For Rockchip, I use ffmpeg that comes with jellyfin to do transcoding (HEVC->H264). It works fine with 6.1.115 vendor kernel, I have not used it for camera. It might miss certain things w.r.t. V4L2 controlling camera attributes. Below is what I get on a NanoPi-R6C (RK3588s, Trixie). You can see only JPEG encoder is available. root@ranc:~# uname -a Linux ranc 6.18.0-rc3-edge-rockchip64 #1 SMP PREEMPT Sun Oct 26 22:59:49 UTC 2025 aarch64 GNU/Linux root@ranc:~# ls -al /dev/media* crw-rw----+ 1 root video 238, 0 Nov 4 13:53 /dev/media0 crw-rw----+ 1 root video 238, 1 Nov 4 13:53 /dev/media1 lrwxrwxrwx 1 root root 6 Nov 4 13:53 /dev/media-dec0 -> media0 lrwxrwxrwx 1 root root 6 Nov 4 13:53 /dev/media-dec1 -> media1 root@ranc:~# media-ctl -d 0 -p Media controller API version 6.18.0 Media device information ------------------------ driver hantro-vpu model hantro-vpu serial bus info platform:fdba0000.video-codec hw revision 0x0 driver version 6.18.0 Device topology - entity 1: rockchip,rk3588-vepu121-enc-sou (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video1 pad0: SOURCE -> "rockchip,rk3588-vepu121-enc-pro":0 [ENABLED,IMMUTABLE] - entity 3: rockchip,rk3588-vepu121-enc-pro (2 pads, 2 links) type Node subtype Unknown flags 0 pad0: SINK <- "rockchip,rk3588-vepu121-enc-sou":0 [ENABLED,IMMUTABLE] pad1: SOURCE -> "rockchip,rk3588-vepu121-enc-sin":0 [ENABLED,IMMUTABLE] - entity 6: rockchip,rk3588-vepu121-enc-sin (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video1 pad0: SINK <- "rockchip,rk3588-vepu121-enc-pro":1 [ENABLED,IMMUTABLE] root@ranc:~# media-ctl -d 1 -p Media controller API version 6.18.0 Media device information ------------------------ driver hantro-vpu model hantro-vpu serial bus info platform:fdc70000.video-codec hw revision 0x0 driver version 6.18.0 Device topology - entity 1: rockchip,rk3588-av1-vpu-dec-sou (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video2 pad0: SOURCE -> "rockchip,rk3588-av1-vpu-dec-pro":0 [ENABLED,IMMUTABLE] - entity 3: rockchip,rk3588-av1-vpu-dec-pro (2 pads, 2 links) type Node subtype Unknown flags 0 pad0: SINK <- "rockchip,rk3588-av1-vpu-dec-sou":0 [ENABLED,IMMUTABLE] pad1: SOURCE -> "rockchip,rk3588-av1-vpu-dec-sin":0 [ENABLED,IMMUTABLE] - entity 6: rockchip,rk3588-av1-vpu-dec-sin (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video2 pad0: SINK <- "rockchip,rk3588-av1-vpu-dec-pro":1 [ENABLED,IMMUTABLE] 0 Quote
The Tall Man Posted 3 hours ago Posted 3 hours ago My understanding is that ffmpeg needs to be compiled to do hardware acceleration. I use it (straight from the Debian repository) to transcode videos on my RK3588 board (Orange PI 5 Plus) running the Armbian edge kernel, and it runs just as fast as the vendor-compiled ffmpeg did using the Orange Pi company's vendor kernel. 0 Quote
eselarm Posted 2 hours ago Posted 2 hours ago 19 minutes ago, The Tall Man said: My understanding is that ffmpeg needs to be compiled to do hardware acceleration. I use it (straight from the Debian repository) to transcode videos on my RK3588 board (Orange PI 5 Plus) running the Armbian edge kernel, and it runs just as fast as the vendor-compiled ffmpeg did using the Orange Pi company's vendor kernel. There should be a big difference in speed and powerconsumption; As I indicated in earlier post, edge kernel has no video encoding working, so at least is is SW encode. Debian/standard ffmpeg for aarch64 only had/has v4l2m2m, no dedicated RKMPP also no old OpenMAX rpi methods (in the past). I think this works for Qualcomm SoCs, but no others I am aware of. If you use RK35xx RKMPP I see almost 5x real-time speed for 1080p50 and low CPU load. See example below: root@rock5b:~# ffmpeg -hide_banner -codecs | grep -e h264_v4l2m2m -e h264_rkmpp DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_cuvid) (encoders: libx264 libx264rgb h264_nvenc h264_v4l2m2m h264_vaapi h264_vulkan) root@rock5b:~# /usr/share/jellyfin-ffmpeg/ffmpeg -hide_banner -codecs | grep -e h264_v4l2m2m -e h264_rkmpp DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_rkmpp h264_cuvid) (encoders: libx264 libx264rgb h264_nvenc h264_v4l2m2m h264_rkmpp) root@rock5b:~# /usr/share/jellyfin-ffmpeg/ffmpeg -y -hide_banner -c:v hevc_rkmpp -i /lan/record/2025-11-04-NPO-1.ts -map v -c:v h264_rkmpp -f mpegts /dev/null Input #0, mpegts, from '/lan/record/2025-11-04-NPO-1.ts': Duration: 06:59:01.58, start: 14798.887378, bitrate: 4058 kb/s Program 1 Metadata: service_name : NPO 1 service_provider: KPN Stream #0:0[0x1b63]: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn Stream #0:1[0x1b64](dut): Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp Stream #0:2[0x1b69](dut): Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp (visual impaired) (descriptions) Stream #0:3[0x1b65](dut): Subtitle: dvb_teletext (libzvbi_teletextdec) ([6][0][0][0] / 0x0006), 492x250 No Program Stream #0:4[0x12]: Data: epg Stream mapping: Stream #0:0 -> #0:0 (hevc (hevc_rkmpp) -> h264 (h264_rkmpp)) Press [q] to stop, [?] for help Output #0, mpegts, to '/dev/null': Metadata: encoder : Lavf61.7.100 Stream #0:0: Video: h264 (High), nv12(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 50 fps, 90k tbn Metadata: encoder : Lavc61.19.101 h264_rkmpp ^C[out#0/mpegts @ 0xaaaaea74fce0] Error writing trailer: Immediate exit requesteds speed=4.86x [out#0/mpegts @ 0xaaaaea74fce0] Error closing file: Immediate exit requested [out#0/mpegts @ 0xaaaaea74fce0] video:61287KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 6.096897% frame=12559 fps=244 q=25.0 Lsize= 65024KiB time=00:04:11.16 bitrate=2120.9kbits/s speed=4.87x ^C^CReceived > 3 system signals, hard exiting 0 Quote
usual user Posted 1 hour ago Posted 1 hour ago (edited) 2 hours ago, eselarm said: Below is what I get on a NanoPi-R6C (RK3588s, Trixie). You can see only JPEG encoder is available. My rk3588 devices are e.g. exposing this: v4l2-compliance-odroid-m2.txt And here is the visualization of a video pipeline: video-pipeline.pdf Watch out for the v4l2slh265dec component. Edited 1 hour ago by usual user 0 Quote
eselarm Posted 1 hour ago Posted 1 hour ago I just did a simple test that always worked on Intel CPUs with with logitech C310 on ROCK5B with 6.1.115 kernel /usr/share/jellyfin-ffmpeg/ffmpeg -y -hide_banner -f video4linux2 -input_format yuv420p -video_size 640x480 -framerate 30 -i /dev/v4l/by-id/usb-046d_081b_9061E8E0-video-index0 -map v -c:v h264_rkmpp -f mpegts webcam.ts Output file plays fine, good motion, same as if I use normal ffmpeg and just non-accel h264 codec, although CPU load is then about 20% for the ffmpeg process, while when using rkmpp it is below 1% For higher resolution, I think C310 internal MJPG is needed, but that is normal, USB2 has limited bandwidth. 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.