🛠 Serveur multimédia : Kodi, décodage 4K et accès GPU en conteneur
Objectives
Turn the Pi 4B into a media center: the VideoCore VI running at 500 MHz decodes H.265 4Kp60 and H.264 1080p60, the dual micro-HDMI outputs display up to 4K, and the open-source Mesa V3D driver (Vulkan 1.2 compliant since 2022) also allows exposing the GPU to containers. You will install Kodi and launch a container with GPU access.
Hardware
- Raspberry Pi 4B (4 GB or more recommended), 5.1 V 3 A power supply
- TV with micro-HDMI or high-quality HDMI adapter (6 Gbps required for 4Kp60)
- USB 3.0 drive for the library; sudo apt install docker.io
Complete code
# Option A - media center dedie : flasher LibreELEC (Kodi) avec Raspberry Pi Imager
# Verification : Lecture 4K HEVC fluide, menu en 60 i/s sur les deux ports micro-HDMI.
# Option B - Kodi/Docker avec GPU sur Raspberry Pi OS Bookworm :
sudo usermod -aG video "$USER"
ls -l /dev/dri # rendre visible card0 (V3D)
docker run -d --name kodi --restart unless-stopped \
--privileged --net host \
-v /dev:/dev -v /mnt/media:/data \
linuxserver/kodi
# Controles :
vcgencmd version # firmware a jour
vcgencmd measure_temp # < 70 degres en lecture 4K
Expected verification
When playing a 4K H.265 file, the CPU stays below 30% (everything is decoded by the GPU), the display outputs 3840x2160 at 60 Hz on one port, and the second can display the desktop in 1080p. Inside the container, ls /dev/dri shows card0: the GPU is visible.
Common errors
- Low-quality micro-HDMI adapter: the classic case of no image, you need certified 6 Gbps.
- Forgetting
/dev/driin the container or thevideogroup: the GPU remains invisible. - Overheating during prolonged 4K playback: ensure proper ventilation, the limit is 85 degrees.
- Exceeding USB budget: max 1.2 A for peripherals, a powered 2.5-inch drive is required.
- Expecting 4Kp60 on BOTH ports: dual display is limited to 4Kp30 on each.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython