Skip to content

Raspberry Pi

WangBin edited this page Oct 13, 2023 · 9 revisions

About SDK for Raspberry Pi

RECOMMEND to use generic linux arm64 sdk for rpi3/4

Hardware Decoders

  • V4L2M2M: or "FFmpeg:hwaccel=v4l2m2m". Supports h264
  • FFmpeg:hwcontext=drm: use the latest RaspberryPi OS system ffmpeg. Supports hevc
  • mmal: builtin mmal decoder implementation. available in legacy 32bit sdk for rpi
  • MMAL: FFmpeg mmal decoder implementation. available in legacy 32bit sdk for rpi

Mesa Driver and V4L2

In the latest RaspberryPi OS(debian11/12), system ffmpeg or https://github.com/jc-kynesim/rpi-ffmpeg supports v4l2m2m decoder and hevc hardware decoder, both can produce drm_prime frames. To use system ffmpeg, delete libffmpeg.so.? in sdk package. It's better to use OpenGLES + EGL.

./glfwplay -log all -c:v V4L2M2M,FFmpeg:hwcontext=drm:sw_fallback=1 -gl test.mp4

-gl option will create an EGL + OpenGLES context by libmdk

NOTE: if run in an x11 terminal, displaying log in the terminal may slow down video rendering, either redirect log or disable log

In wayland, the performance is better. glfw wayland is required for glfwplay example

sudo apt install libglfw3-wayland
./glfwplay -log all -c:v V4L2M2M,FFmpeg:hwcontext=drm:sw_fallback=1 -es test.mp4

-es option tells glfw to create an OpenGLES context, not created by libmdk

Legacy SDK

Legacy 32bit sdk for rpi is cross built by latest clang release with modified rpi1 sysroot and ffmpeg with userland mmal. Now it's not enabled in ci. It should run in glibc 2.12 (ubuntu 12.04) environment. Supports both mesa driver and brcm dispmanx.

pi 4: ALSA_DEVICE=sysdefault

legacy sdk warning: clang >= 9 result dso can not be loaded on rpi1, maybe there is a bug in lld

Legacy VC4 Environment

In vc4/6 driver environment(fake/full kms), MMAL hardware decoder is available, but zero copy rendering is not

  • vc4/6 egl+es2: ./window -c:v MMAL test.mp4
  • vc4/6 glx: GL_ES=0 ./window -c:v MMAL test.mp4 # if not link against libGL or libOpenGL
  • vc4/6 wayland: ./window -c:v MMAL test.mp4 # assume weston is running in x11 or CLI mode via weston-launch
  • vc4/6 gbm: ./window -surface gbm -c:v MMAL test.mp4 # assume weston is running # in CLI mode

BRCM Firmware Environment

In legacy driver environment, hardware decoder (MMAL, mmal) supports zero copy rendering in GLES2 and has the best performance

  • legacy driver gles2 in window example: ./window -c:v MMAL test.mp4
Clone this wiki locally