Playing Videos In-Game

Hi I’m just getting started with my first game using Urho and haven’t been able to figure out how to play videos (.mp4 ideally) in a window within the game. Can anybody help? :slight_smile:

Welcome to the forums!
Video file playback is not supported by the engine directly. You need to integrate your video player library of choice, create a Texture2D in dynamic mode, and keep updating the texture with SetData() function as your video library decodes frames.

thanks, I’ll try and get that going. Any suggestions for which video player library?

Also, is there a way of making the texture2D a (or child of) UI element ?

Simply assign the texture to a BorderImage UI element to show it. ( BorderImage::SetTexture() ).

ffmpeg.org/

much appreciated!

Hi miz!
Try to translate this tut from RU to ENG with helps G… :slight_smile:

3d-orange.com.ua/video-in-your-g … gg_theora/

Or you may just dig in this source code : (TheoraVideo.zip) 3d-orange.com.ua/wp-content/plug … .php?id=27

I think this is easy way to play videos on textures, and seems that it also may in easy manner ported to Urho3d

I went with ffmpeg in the end as it seemed best supported and cross-platform etc. I did have trouble installing it but managed to get it going in the end.

Does anyone know of any good tutorials for ffmpeg decoding? Having trouble getting going with it, the documentation hasn’t helped much…

There’s a very simple tutorial demonstrating how to get the RGB data, with source code, available at http://dranger.com/ffmpeg/tutorial01.html.
Beware that almost everything in FFmpeg is licensed under LGPL or GPL.

webmproject.org/code/ is BSD license.

Another codec to consider is:
openh264.org/

The patent covering is all on cisco, and if you target mobile what I recommend is to target the platform’s API so you get the hardware decoder, and only use openh264 on the desktop or as a fallback. WebM is cool too, just you might not find hardware that decodes it.

Hi, I still haven’t got things quite working. Can anyone help?

I’m setting up my Texture2D as follows:
BorderImage* video = new BorderImage(context_); video->SetSize(640, 480); vidtexture = new Texture2D(context_); video->SetTexture(vidtexture); video->SetAlignment(HA_CENTER, VA_CENTER); window_->AddChild(video); uiRoot_->SetDefaultStyle(style); window_ = new Window(context_); uiRoot_->AddChild(window_); window_->SetSize(648, 512); window_->SetName("Window"); vidtexture->SetSize(640, 480, SDL_PIXELFORMAT_RGB24, TEXTURE_DYNAMIC);

I’ve then got very nearly identical code to http://dranger.com/ffmpeg/tutorial01.c except instead of saving 5 frames of data to a file I’m trying this:

Is this the right sort of thing? Any obvious problems?

Currently my BorderImage/Texture is just black…