Professional FFmpeg GDExtension for Godot 4.x, purpose-built for Lymo projection mapping with cross-platform performance on Windows/Linux.
- 🎥 FFmpeg Video Decoder - Supports all major video formats (MP4, AVI, MKV, MOV, WebM)
- ⚡ Hardware Acceleration - CUDA, VAAPI, D3D11VA, DXVA2 support for optimal performance
- 🎨 Custom YUV→RGB Shaders - Advanced color space conversion with BT.601/709/2020 support
- 🎭 Alpha Channel Support - Full RGBA and YUVA format support for compositing
- 🎮 VideoStreamPlayback Integration - Seamless integration with Godot's video system
- 🏗️ Cross-Platform Build System - SCons-based build with Windows/Linux support
- 📐 Projection Mapping Ready - Perspective correction, edge blending, color calibration
- Clone the repository with submodules:
git clone --recursive https://github.com/NaejEL/Lymo-FFmpeg-GDextension.git-
Install dependencies (see BUILD.md for detailed instructions)
-
Build the extension:
scons platform=linux target=template_release # Linux
scons platform=windows target=template_release # Windows- Copy to your Godot project and enable the plugin
# Create FFmpeg decoder
var decoder = FFmpegDecoder.new()
# Enable hardware acceleration
decoder.set_use_hardware_acceleration(true)
# Open video file
if decoder.open_file("path/to/video.mp4"):
print("Video loaded: ", decoder.get_width(), "x", decoder.get_height())
# Decode frames
var frame = decoder.decode_next_frame()
if frame:
# Use the frame image...
pass# Create video stream
var stream = FFmpegVideoStream.new()
stream.set_file("path/to/video.mp4")
# Play in VideoStreamPlayer
var player = VideoStreamPlayer.new()
player.stream = stream
player.play()The extension automatically detects and uses available hardware acceleration:
- NVIDIA: CUDA acceleration
- Intel: VAAPI (Linux), D3D11VA (Windows)
- AMD: VAAPI (Linux), D3D11VA (Windows)
Check available decoders:
var decoder = FFmpegDecoder.new()
print("Available HW decoders: ", decoder.get_available_hw_decoders())
print("Current decoder: ", decoder.get_current_hw_decoder())The extension includes specialized shaders for projection mapping:
- YUV→RGB Conversion:
src/shaders/yuv_to_rgb.gdshader - Video Projection:
src/shaders/video_projection.gdshader
# Set color space for accurate reproduction
decoder.set_color_space(1) # BT.709 for HD content
decoder.set_color_range(0) # TV range (16-235)
# Get raw frame data for custom processing
var raw_data = decoder.get_raw_frame_data()The included demo project demonstrates:
- Video loading and playback
- Hardware acceleration control
- Real-time video information display
- Projection mapping examples
Run the demo:
cd demo
godot project.godotMain decoder class with hardware acceleration support.
open_file(path: String) -> bool- Open video filedecode_next_frame() -> Image- Decode next video frameseek_to_time(seconds: float) -> bool- Seek to specific timeclose()- Close decoder and free resources
use_hardware_acceleration: bool- Enable/disable HW accelerationwidth: int- Video width (read-only)height: int- Video height (read-only)frame_rate: float- Video frame rate (read-only)duration: float- Video duration in seconds (read-only)
VideoStream implementation for Godot integration.
set_file(path: String)- Set video file pathget_file() -> String- Get current file path
See BUILD.md for detailed build instructions.
# Install dependencies
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
# Build
scons platform=linux target=template_releaseOptimized for real-time projection mapping:
- Zero-copy frame processing where possible
- Efficient YUV→RGB conversion
- Hardware-accelerated decoding
- Minimal memory allocations
| Format | Resolution | Software | Hardware (CUDA) |
|---|---|---|---|
| H.264 | 1920x1080 | 45 fps | 120+ fps |
| H.265 | 3840x2160 | 15 fps | 60+ fps |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- FFmpeg team for the excellent multimedia framework
- Godot Engine team for the powerful game engine
- Contributors and testers from the projection mapping community