Hwaccel on RPi 4

$ dmesg|egrep -i 'v4l|video'

[ 19.591897] bcm2835_vc_sm_cma_probe: Videocore shared memory driver
[ 19.642202] videodev: Linux video capture interface: v2.00
[ 19.744940] bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
[ 19.752261] bcm2835-codec bcm2835-codec: Device registered as /dev/video10
[ 19.752309] bcm2835-codec bcm2835-codec: Loaded V4L2 decode
[ 19.753309] bcm2835-isp bcm2835-isp: Device node output[0] registered as /dev/video13
[ 19.754762] bcm2835-isp bcm2835-isp: Device node capture[0] registered as /dev/video14
[ 19.756546] bcm2835-isp bcm2835-isp: Device node capture[1] registered as /dev/video15
[ 19.757016] bcm2835-isp bcm2835-isp: Device node stats[2] registered as /dev/video16
[ 19.757343] bcm2835-isp bcm2835-isp: Loaded V4L2 bcm2835-isp
[ 19.766519] bcm2835-codec bcm2835-codec: Device registered as /dev/video11
[ 19.766565] bcm2835-codec bcm2835-codec: Loaded V4L2 encode
[ 19.787810] bcm2835-codec bcm2835-codec: Device registered as /dev/video12
[ 19.787861] bcm2835-codec bcm2835-codec: Loaded V4L2 isp
[ 19.804630] bcm2835-codec bcm2835-codec: Device registered as /dev/video18
[ 19.804677] bcm2835-codec bcm2835-codec: Loaded V4L2 image_fx

$ lsof -n -p $(pidof ffmpeg-dl) | grep dev/v

ffmpeg-dl 7482 pi mem CHR 81,6 246 /dev/video12
ffmpeg-dl 7482 pi 7u CHR 81,6 0t0 246 /dev/video12
ffmpeg-dl 7482 pi 8u CHR 242,0 0t0 133 /dev/vchiq

So it seems the V4L2 encode is not used .....

Here is a difference between stock and channels supplied ffmpeg

$ ./ffmpeg -hwaccels
Hardware acceleration methods:
drm

$ ffmpeg -hwaccels 2>/dev/null
Hardware acceleration methods:
vdpau
vaapi
drm
rpi
rpi

We currently only use V4L2 on 64-bit OS. I've added it to HWE test for 32-bit OS with v2021.11.29.2014

Is there a performance difference when transcoding between 64 bit and 32 bit OS on RPi 4?
The answer to this question would allow me to decide if I should switch to 64 bit.

Yes there is a difference in performance, but I don't recall how much. 100% cpu does not sound normal.

What does the HWE test show in logs now with the latest prerelease?

Same as in the beginning. I think it is too fast to generate anything.

2021/11/29 17:23:29.537975 [HTTP] | 200 | 241.755µs | ::1 | POST "/hls/hwaccel"

Did you update to the correct build?

Version

2021.11.23.2219

So.. no?

Didn't know there is a prerelease. Kicked the updater with

$ curl -XPUT http://localhost:8089/updater/check/prerelease

need 5 more minutes as the TV is being used. Now you know why I asked for a graceful upgrade :wink:

Summary

2021/11/29 17:40:49.930171 [HWE] Trying v4l2m2m: /home/pi/channels-dvr/2021.11.29.2014/ffmpeg /home/pi/channels-dvr/2021.11.29.2014/ffmpeg -hide_banner -nostats -loglevel warning -loglevel verbose -f lavfi -t 0.1 -i color=black:640x480 -f null -c:v h264_v4l2m2m -profile:v high -level 42 -b:v 400k -maxrate:v 600k -y /dev/null
[Parsed_color_0 @ 0x21b1b60] size:640x480 rate:25/1 duration:-1.000000 sar:1/1
Input #0, lavfi, from 'color=black:640x480':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m))
Press [q] to stop, [?] for help
[graph 0 input from stream 0:0 @ 0x21dc6f0] w:640 h:480 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
[h264_v4l2m2m @ 0x21da650] Using device /dev/video11
[h264_v4l2m2m @ 0x21da650] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode
[h264_v4l2m2m @ 0x21da650] requesting formats: output=YU12/yuv420p capture=H264/none
Output #0, null, to '/dev/null':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (h264_v4l2m2m) (High), 1 reference frame, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 400 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc58.54.100 h264_v4l2m2m
No more output streams to write to, finishing.
frame= 3 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.12 bitrate=N/A speed=2.95x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (color=black:640x480):
Input stream #0:0 (video): 4 packets read (1843200 bytes); 4 frames decoded;
Total: 4 packets (1843200 bytes) demuxed
Output file #0 (/dev/null):
Output stream #0:0 (video): 3 frames encoded; 4 packets muxed (183 bytes);
Total: 4 packets (183 bytes) muxed
2021/11/29 17:40:49.988957 [HWE] Successfully encoded using v4l2m2m

Looks like its using v4l2 now.

btw: when restarting from the command line

$ sudo systemctl restart channels-dvr
Warning: The unit file, source configuration file or drop-ins of channels-dvr.service changed on disk. Run 'systemctl daemon-reload' to reload units.

Also over 100% on CPU usage when transcoding

$ top -u pi -d 1 -n 2 -b

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
 8741 pi        20   0  255396  34424   6256 S 117.6   0.4   0:08.58 ffmpeg-dl
 7950 pi        20   0 1270744  84916  54152 S  56.9   1.0   6:32.46 channels-dvr

Okay. I don't have my Pi handy to compare. Maybe someone else can post their results. It may be normal.

1 Like

Upgraded to prerelease 11/29 and encoding is working on OTA HD channels now on 32bit OS. also shows over 100% CPU on ffmpeg-dl.

Edit: Does pause/buffer, but can't say it's more than before when I was using the Official image. I just don't use this feature enough to say it's different than before.

The latest version uses codec h264_omx and not h264_v4l2m2m.

v4l2 is about 50% faster. speed=1.07 vs 1.65 # both with ffmpeg-dl

John Van Sickle - FFmpeg Static Builds

These binaries achieve even higher speeds, over 1.9x

Not trying to hi-jack this thread, but my Pi4 only shows Software as well. I am running Ubuntu x64. Logs below:

2021/12/05 18:19:31.359338 [HWE] Trying nvmpi: /home/user/channels-dvr/2021.12.03.1543/ffmpeg-dl /home/user/channels-dvr/2021.12.03.1543/ffmpeg-dl -hide_banner -nostats -loglevel warning -loglevel verbose -f lavfi -t 0.1 -i color=black:640x480 -f null -c:v h264_nvmpi -profile:v high -level 42 -b:v 400k -maxrate:v 600k -y /dev/null
/home/user/channels-dvr/2021.12.03.1543/ffmpeg-dl: error while loading shared libraries: libnvmpi.so: cannot open shared object file: No such file or directory
2021/12/05 18:19:31.362079 [HWE] Failure: exit status 127
2021/12/05 18:19:31.362146 [HWE] Trying v4l2m2m: /home/user/channels-dvr/2021.12.03.1543/ffmpeg /home/user/channels-dvr/2021.12.03.1543/ffmpeg -hide_banner -nostats -loglevel warning -loglevel verbose -f lavfi -t 0.1 -i color=black:640x480 -f null -c:v h264_v4l2m2m -profile:v high -level 42 -b:v 400k -maxrate:v 600k -y /dev/null
[Parsed_color_0 @ 0x3946b260] size:640x480 rate:25/1 duration:-1.000000 sar:1/1
Input #0, lavfi, from 'color=black:640x480':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m))
Press [q] to stop, [?] for help
[graph 0 input from stream 0:0 @ 0x39496770] w:640 h:480 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
[h264_v4l2m2m @ 0x39494350] Could not find a valid device
[h264_v4l2m2m @ 0x39494350] can't configure encoder
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
2021/12/05 18:19:31.382444 [HWE] Failure: exit status 1