Playing MP4 video


I’m using Windows 10, VS 2015 Update 3 and MonoGame 3.5.1, DirectX.

I’m trying to play a video inside the game and I tried using a .WMV and it works as expected, however when I try to play an .MP4 video (using the same code used to play the .WMV) I get the following exception in the VideoPlayer.GetTexture() statement:

An unhandled exception of type ‘System.InvalidOperationException’ occurred in MonoGame.Framework.dll

Additional information: Platform returned a null texture

Here’s the statement causing the exception

// VideoPlayer player;
Texture2D videoTexture = player.GetTexture();

Can anyone tell me possible causes for this exception?

Thank you.

I know this reply is four years late, but well… maybe someone would find it useful. MP4 videos won’t work for me either, however if you encode the video in AVI format with mp4 codec (MPEG-4 AVC/H.264), it works perfectly fine and you get the quality and size of a normal mp4. Have in mind that re-encoding an already compressed file, further degrades quality. AVI is a container for the MP4 stream, so there might be tools that allow you to make a lossless conversion (by copying the stream), need to investigate further.

(EDIT: FFMPEG lets you do direct stream copies between different formats)