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 [email protected]:VersaYT/godot_mpv.git
Cd into dependencies folder and clone mpv-build
cd godot_mpv && cd dependencies
git clone https://github.com/mpv-player/mpv-build.git
cd mpv-build
Fetch mpv packages
./rebuild -j4
The -j4
asks it to use 4 parallel processes.
Install mpv
sudo ./install
cd at the root directory of the project Configure CMake for the project
cmake -S . -D CMAKE_BUILD_TYPE=Debug -B ./build
Compile the project (you can of course allow more threads when compiling "-j8")
cmake --build ./build -j4
Requirements
- GCC compiler for windows (can be downloaded here)
- A compiled version of libmpv (you can find one here sourceforge)
- ANGLE (for EGL and GLES2 headers) (will be installed in the project when you use
CMake .
command) - vcpkg (to retrieve ANGLE library)
- 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)
GCC compiler setup (if you don't have it)
- Download and extract the archive found in the website linked above (any version > GCC 12)
- Type "Env" in windows search and click on "edit system environment variables"
- Click on "environment variables"
- Look in "system variables" for your "Path" variable
- Add a new line to this variable
- Copy and paste the path to the previously extracted gcc compiler (we want to target the bin/ folder) for example
C:\mingw64\bin
Install CMake (link above)
Clone the project
git clone git@github.com:VersaYT/godot_mpv.git
Pull vcpkg submodule
cd godot_mpv
git submodule update --init
cd into dependencies folder
cd dependencies
Download libmpv and GLAD from the links above
- Create an
mpv-dev
folder and extract the content of downloaded mpv into it - Create a
glad
folder and extract content of downloaded GLAD into it
From powershell, 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 . -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug
Compile the project (you can of course allow more threads when compiling "-j8")
mingw32-make -j4