Skip to content

benoitliard/video-player

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

4K Video Player for Raspberry Pi 5

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)

Stars Forks Issues License

🚀 Features

  • 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 ... //

🎮 WebSocket Control

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.

📋 Requirements

Hardware

  • Raspberry Pi 5
  • Minimum 4GB RAM (8GB recommended for 4K)
  • HDMI 2.0 compatible display for 4K

Dependencies

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-dev

🛠️ Build

mkdir build
cd build
cmake ..
make -j4

📦 Usage

./video_player path/to/video.mp4

🚀 Performance

  • 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

🤝 Contributing

Contributions are welcome! Here are some priority areas for improvement:

  1. Additional RPi 5 optimizations
  2. Support for more codec formats
  3. UI improvements
  4. Documentation translations

Please read our Contributing Guidelines before submitting a PR.

📊 Benchmarks

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

🏗️ Architecture

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
Loading

📊 Class Diagram

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
Loading

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Show your support

Give a ⭐️ if this project helped you!


Made with ❤️ for the Raspberry Pi community

📧 Contact

About

4K Video Player for Raspberry Pi 5 for standalone installation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published