This repository is an outdated backup of a previous project. It is no longer maintained or updated.
It is hosted here solely for preservation purposes.
An experimental library aiming to make video playback in MonoGame possible. Only for DesktopGL on Windows
-
Download or compile FFmpeg, which is a required component to stream your video into raw format. Place the
ffmpeg
executable somewhere near your game. (ffprobe
andffplay
are not needed!).
Development tests and examples use pre-compiledffmpeg_essentials_build
byGyanD
: Latest version -
Set the path to your
ffmpeg
executable:
You must do this before creating any
Video
instance!
Video.SetFFmpegExecutablePath(Path.Combine("lib", "ffmpeg.exe"));
- Create a
Video
instance and provide the path to your video and an instance of the graphics device:
var myVideo = new Video(Path.Combine("Content", "video.mp4"), _graphics.GraphicsDevice);
- Start the video playback. This will also load the metadata if you haven't done so already (see Optimization):
myVideo.Play();
- Update the video and draw the current frame:
protected override void Update(GameTime gameTime)
{
myVideo.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
_spriteBatch.Begin();
if (videoPlayer.CurrentFrame is not null) // Check whether the video is playing, or you'll get a null texture!
_spriteBatch.Draw(myVideo.CurrentFrame, Vector2.Zero, Color.White);
_spriteBatch.End();
}
And that's it! Your video is now streaming from the disk!
👉 Also check out the minimal example!
¯\_(ツ)_/¯