Jump to content
Vulcan

Video player

Recommended Posts

I think Leadwerks should have a video player for the purpose to show intro video and game scenes.

Yesterday I did make short intro video (6 sec, compressed AVI, ~2 MB) in Blender that was good but did not have an easy way to play this intro when game start.

 

I suggest having a Cinema class that play a video in window/fullscreen with Play/Stop.

Cinema* intro = new Cinema("Video/intro.avi");
if(intro->isLoaded())
intro->Play();
intro->Unload();
delete intro;

 

 

As a temporary solution I made a cinema class and all works pretty well, except for that it takes about ~500 MB. And it uses *.tex files as each frame (0001.tex -> 0099.tex in my case).

Cinema.txt

Share this post


Link to post

Have a look at this;

https://icculus.org/theoraplay/

 

Theora migth not be the best format - but it's defintiviely better than 500mb for 6 sec of video and it's unencumbered by patents

Unfortunately TheoraPlay is based on C code, after digging around the net I found something called libtheoraplayer which is C++ based and so far looks good.

Share this post


Link to post

Well those files only work with Le2 anyway. A custom dll was created for LE2 to support video directly in the editor.

Share this post


Link to post

Could you adapt it to work in your own LE3 code? Probably much better than starting from scratch, even if it doesn't work in the editor.

Share this post


Link to post

Unfortunately TheoraPlay is based on C code, after digging around the net I found something called libtheoraplayer which is C++ based and so far looks good.

 

Any why would that be a problem?blink.png

Share this post


Link to post

I am not sure how I would implement this with Leadwerks. How do I put video frame onto a Leadwerks::Texture ?

Share this post


Link to post

I have tryied to get TheoraPlay to work with Leadwerks. I do get pixel data but when trying to assign that data to Leadwerks::Texture then I get a run-time error. How do I remedy this? Only thing I can think of now is to iterate through each pixels but that would probably be slow as turtle.

 

void TestState::Enter()
{
//bunny.ogg: 720x400
const char* filename = "bunny.ogg";
int video_w = 720;
int video_h = 400;
texture = Texture::Create(nextPow2(video_w), nextPow2(video_h), Leadwerks::Texture::RGB);

THEORAPLAY_VideoFormat vidfmt = THEORAPLAY_VIDFMT_YV12; // <----- Probably wrong format. VLC reports YUV
THEORAPLAY_Decoder *decoder = NULL;
const THEORAPLAY_VideoFrame *video = NULL;
const THEORAPLAY_AudioPacket *audio = NULL;
decoder = THEORAPLAY_startDecodeFile(filename, 20, vidfmt);
while (THEORAPLAY_isDecoding(decoder))
{
 video = THEORAPLAY_getVideo(decoder);
 if (video)
 {
  printf("Got video frame (%u ms)!\n", video->playms);
  texture->SetPixels((const char*)video->pixels); // <------- Runtime error: "Unhandled exception"
  THEORAPLAY_freeVideo(video);
 } // if
 audio = THEORAPLAY_getAudio(decoder);
 if (audio)
 {
  printf("Got %d frames of audio (%u ms)!\n", audio->frames, audio->playms);
  THEORAPLAY_freeAudio(audio);
 } // if
 if (!video && !audio)
  Sleep(10);
} // while
if (THEORAPLAY_decodingError(decoder))
 printf("There was an error decoding this file!\n");
else
 printf("done with this file!\n");
THEORAPLAY_stopDecode(decoder);
}

howtovideo.txt

Share this post


Link to post

WOOOHHOOOO!! I got it playing with Big Buck Bunny, only need to play it with correct speed and audio smile.png

Share this post


Link to post

WOOOHHOOOO!! I got it playing with Big Buck Bunny, only need to play it with correct speed and audio smile.png

 

That is nice, however since this thread will likely show up in the search it would be nice if you posted the solution also ;)

Share this post


Link to post

I have been trying to learn about how TheoraPlay handles sound and found out the sound data is within struct packets called THEORAPLAY_AudioPacket. But so far I haven't figured out how to implement this with Leadwerks. I have looked at Leadwerks header files: Sound.h and Bank.h but seems like "Bank* data" is holding all sound data. My problem is I am not sure how to append more sound data as new sound packets are arriving from TheoraPlay.

 

audio = THEORAPLAY_getAudio(decoder);
if (audio)
{
   printf("Got %d frames of audio (%u ms)!\n", audio->frames, audio->playms);

   // <------ How do I add sound data to Leadwerks::Sound ?

   THEORAPLAY_freeAudio(audio);
} // if

Share this post


Link to post

I really wish LETheora would work. Currently it's not. I know small game designers should not focus on cut scenes and movies. But I think this is diffrent. The ability to play video inside leadwerks would be great because it would allow stuff like talking pictures, old television sets, shock effects where texture suddenly change into some scary movie clip and a whole lot of other cool stuff.

Share this post


Link to post

Dumb question probably... but couldnt you make your video into an animated texture or something ?(adding sound to it)(or a series of linked animated textures) ...I say texture since GIFs dont seem to work in Leadwerks 3 ..its not seeing it..

Share this post


Link to post

I'd happily settle for being able to do something like

 

exec "/usr/bin/mplayer2 ./my_awesome_cutscene.mp4"

 

in lua before loading the next map. Even cooler would be if I could get it to do that, load a map in the background and wait for the video to end before jumping into the map.

Share this post


Link to post

Have you looked into 3rd party libraries that maybe would make a window on top of LE's? It might be hacky but if you could have this video window on top of LE's then they would be completely separate. You could launch this window from LE before map loading and then after map loading you kill the window. Could be a possible workaround. You could even probably hide the task bar part of the window so it doesn't really look like it's 2 separate processes and could probably make the video window always on top.

Share this post


Link to post

Dumb question probably... but couldnt you make your video into an animated texture or something ?(adding sound to it)(or a series of linked animated textures) ...I say texture since GIFs dont seem to work in Leadwerks 3 ..its not seeing it..

 

this is a actually good solution for short animations. But it can never replace a real video player with audio

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...