Jump to content

Video player


Vulcan
 Share

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ;)

  • Upvote 1

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 months later...

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.

Link to comment
Share on other sites

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..

Threadripper 2920X Gen2 CPU(AMD 12-core 24 thread) | 32Gigs DDR4 RAM | MSI Nvidia GeForce RTX 2070 Stock OCed | ASRock X399 Professional Gaming Motherboard | Triple M.2 500Gig SSD's in Raid0

Windows 10 Pro | Blender | Paint.NetWorld Machine | Shader Map 4 | Substance Designer | Substance Painter | Inkscape | Universal Sound FX | ProBuilder | 3D World Studio | Spacescape | OpenSky | CubeMapGen | Ecrett Music | Godot Engine | Krita | Kumoworks | GDScript | Lua | Python | C# | Leadworks Engine | Unity Engine

 

Link to comment
Share on other sites

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.

content over form, game play over all.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...