A high-performance video player optimized for Raspberry Pi 5, capable of playing 4K videos with audio/video synchronization and WebSocket control.
Perfect for permanent installations on Raspberry Pi 5 (video mapping, digital signage, interactive displays)
- 4K video playback with hardware acceleration via KMSDRM
- Precise audio/video synchronization (±10ms)
- Optimized multi-threaded decoding
- Supported codecs:
- H.264/AVC
- H.265/HEVC
- AAC (audio)
- Smart audio/video buffer management
- Integrated logging system
- Automatic video looping
- Clean signal handling (Ctrl+C)
- Remote control via WebSocket
// ... Garder les diagrammes Mermaid inchangés ... //
Remote control via WebSocket (default port 9002). Available commands:
{"token": "your_token", "command": "play"}
{"token": "your_token", "command": "pause"}
{"token": "your_token", "command": "stop"}
{"token": "your_token", "command": "reset"}
{"token": "your_token", "command": "volume", "value": 50}Authentication token is generated at startup and displayed in logs.
- Raspberry Pi 5
- Minimum 4GB RAM (8GB recommended for 4K)
- HDMI 2.0 compatible display for 4K
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
libsdl2-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libswresample-dev \
libavfilter-devmkdir build
cd build
cmake ..
make -j4./video_player path/to/video.mp4- 4K H.264 decoding: up to 60 FPS
- Audio latency < 50ms
- CPU usage: ~40% on RPi 5
- RAM usage: ~200MB for 4K
- A/V sync: ±10ms
Contributions are welcome! Here are some priority areas for improvement:
- Additional RPi 5 optimizations
- Support for more codec formats
- UI improvements
- Documentation translations
Please read our Contributing Guidelines before submitting a PR.
View detailed performance metrics
| Resolution | Codec | FPS | CPU Usage | RAM Usage |
|---|---|---|---|---|
| 4K (2160p) | H.264 | 60 | 40% | 200MB |
| 4K (2160p) | H.265 | 60 | 35% | 180MB |
| 1080p | H.264 | 60 | 15% | 100MB |
| 1080p | H.265 | 60 | 12% | 90MB |
graph TD
A[VideoPlayer] --> B[VideoDecoder]
A --> C[AudioManager]
A --> D[Renderer]
A --> E[WebSocketController]
B --> F[FFmpeg Decoder]
C --> G[SDL Audio]
D --> H[SDL Video/KMSDRM]
E --> I[WebSocket Server]
B -.-> |Audio Frames| C
B -.-> |Video Frames| D
I -.-> |Commands| A
classDiagram
class VideoPlayer {
-AudioManager audioManager
-VideoDecoder decoder
-Renderer renderer
-WebSocketController wsController
-bool isRunning
+initialize(string path, uint16_t port)
+play()
+pause()
+stop()
+reset()
+setVolume(int)
}
class WebSocketController {
-Server server
-string authToken
-map connections
+initialize(string address, uint16_t port)
+start()
+stop()
-handleCommand(string)
}
class VideoDecoder {
-AVFormatContext* formatContext
-AVCodecContext* codecContext
-queue~AVFrame*~ frameQueue
+initialize(string path)
+getNextFrame()
+startDecoding()
+stopDecoding()
}
class AudioManager {
-SwrContext* swr_ctx
-SDL_AudioDeviceID deviceId
-queue~AVFrame*~ audioQueue
+initialize(AVCodecContext*, AVStream*)
+pushFrame(AVFrame*)
+getAudioClock()
}
class Renderer {
-SDL_Window* window
-SDL_Renderer* renderer
-SDL_Texture* texture
-SwsContext* swsContext
+initialize(int width, int height)
+renderFrame(AVFrame*)
}
VideoPlayer --> WebSocketController
VideoPlayer --> VideoDecoder
VideoPlayer --> AudioManager
VideoPlayer --> Renderer
This project is licensed under the MIT License - see the LICENSE file for details.
Give a ⭐️ if this project helped you!
- GitHub: @benoitliard