+4 votes

Hello!
is it possible to load a video files(specifically, mpg and avi files) and play it?
tried to use VideoPlayer before, but I cant find out how to use it.

in Engine by (485 points)

I think Godot can play Theora videos (.ogv) but I never tried it yet.

2 Answers

+4 votes
Best answer

Godot can currently only decode Ogg Theora (file extension: .ogg or .ogv). Take a look at the VideoPlayer class.

You can encode videos for Ogg Theora using tools like FFmpeg.

by (10,952 points)
selected by

Note that there is also OS.native-video-play() that should play mp4 (and some others) on Android and iPad devices.

+1 vote

If you only want to play fullscreen video with sound (and eventually subtitles), you can include ffplay from ffmpeg into a sub directory of your project, and run it using the OS.execute() function.

extends Control

var pid = null;

func _ready(): #{
    pass
#}

func play(videopath): #{
    pid = OS.execute("bin/ffplay",["-autoexit", "-exitonkeydown", "-exitonmousedown", "-fs", videopath ],true); 
#}

func _on_Play_pressed(): play("video/test.mp4");

According to my test, under Windows, specifying the .exe extension is not mandatory. This mean this code should work on all platforms.

by (20 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.