Video recording of Kodi using ffmpeg

I’m trying to record video of Kodi, to send with a bug report. I’ve installed ffmpeg from the CoreELEC repo and can record using:-

ffmpeg -f fbdev -i /dev/fb0 -r 30 -c:v flv -b:v 500000 out.mkv

This records fine and gives a valid mkv file with a framerate of about 3fps, which is to be expected as it’s a software encoder.

However if I try to use hardware encoding:-

ffmpeg -f fbdev -i /dev/fb0 -r 30 -c:v h264_v4l2m2 -b:v 500000 out.mkv

I get the following error:-

[h264_v4l2m2m @ 0x2a4adb0] Could not find a valid device
[h264_v4l2m2m @ 0x2a4adb0] can't configure encoder

If I run:-

v4l2-ctl --list-devices

I get two devices returned:-

amlvideo (amlvideo-000):
amlvideo (amlvideo-001):

Does anybody know how to do hardware encoding using ffmpeg on a ODROID N2?

Think you have a 2 or 3 watt arm device, what these devices do best is send bytes from one place to another without touching anything, in the case of ffmpeg any recoding parameter other than ‘-c copy’ will be a disaster.

Yes a 2 or 3 watt arm device with a h264/h265 hardware encoder… Which is why I’m asking about hardware encoding.

Try playing a 4K h265 file using software decoding and you will max out the CPU and it will play like trash… Now use the hardware decoder and it plays as expected, same thing with encoding, do it in software and you get 3fps but do it using the hardware encoder and you get much much better performance.

Simply not true… That’s the whole point of hardware decoding/encoding, take a data stream encode or decode it in to a different format and output it.

Really the first questions I need answering are:-

  1. Are the hardware encoders accessible in CoreELEC?
  2. If so can they be used with ffmpeg?

I think NO is answer on both questions.

Thanks, at least I know now not to keep trying :+1:

Sorry, quick follow up question, if the hardware encoders aren’t available in CoreELEC then why does ffmpeg list them?

CoreELEC:~ # ffmpeg -encoders
ffmpeg version 4.4.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.2.0 (GCC)

 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)

I have no real knowledge about this. And I didn’t saw anywhere using encoder.
Did you tried to encode with Kodi stopped?

If you think how much work is done in Kodi to use HW decoders and zero work for ffmpeg I doubt it is supported. Are those just SW encoders?

Yep, same error with both Kodi running and stopped.

I don’t think they are software encoders, but reading the message again I think as it states they are just generic ‘Wrappers’ to the underlying hardware which is probably missing the actual drivers.

I am going to show you the hardware acceleration methods of my devices. In the case of my CoreELEC S905X3 device (3 watts of power) I don’t have any, and in the case of my LibreELEC x86_64 (35 watts of power) I have two hardware acceleration methods: vdpau and vaapi

x96air2-ce:~ # ffmpeg -hwaccels
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 8.4.0 (OpenWrt GCC 8.4.0 r2261-8de072e5)
  configuration: --enable-cross-compile --cross-prefix=aarch64-openwrt-linux-gnu- --arch=aarch64 --cpu=cortex-a53 --target-os=linux --prefix=/opt --pkg-config=pkg-config --enable-shared --enable-static --enable-pthreads --enable-zlib --disable-doc --disable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --disable-runtime-cpudetect --enable-lto --enable-neon --enable-vfp --disable-x86asm --enable-gnutls --enable-libopus --enable-small --enable-libmp3lame --enable-gpl --enable-libx264
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Hardware acceleration methods:

LibreELEC:~ # ffmpeg -hwaccels
ffmpeg version 4.2.4 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8.3.0 (GCC)
  configuration: --enable-ffmpeg --disable-ffplay --enable-ffprobe --enable-static --disable-shared --enable-gpl --disable-doc --enable-encoder=h264_vaapi --enable-encoder=hevc_vaapi --enable-encoder=mjpeg_vaapi --enable-encoder=mpeg2_vaapi --enable-encoder=vp8_vaapi --enable-encoder=vp9_vaapi --disable-encoder=h264_nvenc --disable-encoder=hevc_nvenc --enable-hwaccel=h263_vaapi --enable-hwaccel=h264_vaapi --enable-hwaccel=hevc_vaapi --enable-hwaccel=mjpeg_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi --enable-hwaccel=vc1_vaapi --enable-hwaccel=vp8_vaapi --enable-hwaccel=vp9_vaapi --enable-hwaccel=wmv3_vaapi --enable-avresample --disable-lzma --disable-alsa --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --arch=x86_64 --cpu=x86-64 --cross-prefix=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --enable-cross-compile --sysroot=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --sysinclude=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --target-os=linux --nm=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --ar=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --as=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --cc=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --ld=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --pkg-config=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --host-cc=/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ --host-cflags='-march=native -O2 -Wall -pipe -I/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ -Wno-format-security' --host-ldflags='-Wl,-rpath,/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/ -L/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/' --host-extralibs=-lm --extra-cflags='-march=x86-64 -m64 -mmmx -msse -msse2 -mfpmath=sse -fomit-frame-pointer -Wall -pipe -Os -I/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/' --extra-ldflags='-march=x86-64 -m64 -Wl,--as-needed -L/var/lib/jenkins/LE/build4/workspace/Addons/All_Addons-Generic/' --extra-libs=' -lX11' --enable-pic --enable-gnutls --disable-openssl --disable-hardcoded-tables
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Hardware acceleration methods:

Thanks, looking at the CoreELEC version of ffmpeg and it seems like it isn’t even built with the h264/h265 encoders :frowning:

You keep saying 3 watt device like that means anything, the Raspberry PI does hardware encoding of H264 very well and that’s an even lower powered device.

You will need to search the kernel how to use the hardware encoder by yourself. Nobody ever used it.

Maybe the camera module?

Comparing how many devs are there and with the company behind this is not a surprise.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.