This GDextension implements the open-source MPV video player in Godot Engine 4.4. It's capable of playing local and http video stream to your MeshInstance2D or MeshInstance3D plane surfaces.
Usage Installation Build from source
extends Node3D
var mpv_player: MPVPlayer
func _ready():
mpv_player = MPVPlayer.new()
add_child(mpv_player)
mpv_player.initialize()
#Store reference to a MeshInstance3D (plane)
var mesh_instance = $Screen
mpv_player.connect("texture_updated", func(texture):
var material = mesh_instance.get_surface_override_material(0)
if not material:
material = StandardMaterial3D.new()
mesh_instance.set_surface_override_material(0, material)
material.albedo_texture = texture
material.shading_mode = StandardMaterial3D.SHADING_MODE_UNSHADED
)
mpv_player.load_file("res://path/to/your_video.mp4")
mpv_player.play()Download and extract the GDextension files from the release page into your project bin directory.
Requirements
- MPV installed on the system (install step for mpv-build listed in the build steps)
- EGL and OpenGL ES2 (usually comes with GPU drivers, if not present install with the command linked bellow this text)
sudo apt install libegl1-mesa-dev libgles2-mesa-dev- GLAD (to load OpenGL and use EGL/GLES2 headers, use the generator here)
GLAD configuration: EGL 1.5 GLES2 3.2 ✅ Loader
- CMake for project compilation (CMake download page)
Install CMake (link above)
Clone the project
git clone git@github.com:VersaYT/godot_mpv.gitCd into dependencies folder and clone mpv-build
cd godot_mpv && cd dependencies
git clone https://github.com/mpv-player/mpv-build.git
cd mpv-buildFetch mpv packages
./rebuild -j4The -j4 asks it to use 4 parallel processes.
Install mpv
sudo ./installcd at the root directory of the project Configure CMake for the project
cmake -S . -D CMAKE_BUILD_TYPE=Debug -B ./buildCompile the project (you can of course allow more threads when compiling "-j8")
cmake --build ./build -j4Requirements
- MSYS2 (MinGW64) compiler
- A compiled version of libmpv (you can find one here sourceforge)
- ANGLE (for EGL and GLES2 headers)
- GLAD (to load OpenGL and use EGL/GLES2 headers, use the generator here)
GLAD configuration: EGL 1.5 GLES2 3.2 ✅ Loader
- CMake for project compilation
Install CMake
pacman -S mingw-w64-x86_64-cmake
Install ANGLE lib
pacman -S mingw-w64-x86_64-angleproject
Clone the project
git clone git@github.com:VersaYT/godot_mpv.git
cd into dependencies folder
cd dependencies
Download libmpv and GLAD from the links above
- Create an
mpv-devfolder and extract the content of downloaded mpv into it - Create a
gladfolder and extract content of downloaded GLAD into it
From MSYS2 MinGW64, make sure CMake and GCC are working
cmake --version
gcc --version
cd at the root directory of the project Configure CMake for the project
cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug
Compile the project (you can of course allow more threads when compiling "-j8")
cmake --build build -j4
