Jump to content

How to load/play any video file with LUA


Russell
 Share

Go to solution Solved by Josh,

Recommended Posts

Hello team,

I'm working on a little vídeo that i want show on my game's startup. But I found that I can't load an mp4 (h264) video in LUA.

I've tried to dive along old forum posts, but the examples I've found are in C++ and some links inside don't work anymore after the upgrade from leadwerks.com to ultraengine.com

I am testing an initial basic code as the following:

	local IntroVideo = System:CreateVideo()
	IntroVideo:Open("Video/Intro.mp4")
	-- Reproduce el video
	IntroVideo:Play()

But doesn't work. It doesn't give me any error, but doesn't work for me either.

Any ideas on how I can start with this point?

I just want a video to play when the game opens, and then load the starting *.map.

Many thanks ;);););)

 

Link to comment
Share on other sites

Team i need help with this...

All the threads inside the forum that talk about this subject are down or lost. And links inside this threads with the "www.leadwerks.com..." don't work after the change to www.ultraengine.com.

Google can't help me neither, because all the LUA examples I find to play a video, don't work in Leadwerk's LUA.

Many thanks.

Link to comment
Share on other sites

  • Russell changed the title to How to load/play any video file with LUA
  • Solution

Links to the Leadwerks domain should just redirect to the equivalent URL to this domain:
https://www.leadwerks.com/community/topic/62067-how-to-loadplay-any-video-file-with-lua/

Leadwerks doesn't support video files. Ultimately what you need is a series of texture files and an audio file. Any video file loader will just be doing that behind the scenes. You might as well just use ffmpeg or something to extract a series of images.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

25 minutes ago, Josh said:

Links to the Leadwerks domain should just redirect to the equivalent URL to this domain:
https://www.leadwerks.com/community/topic/62067-how-to-loadplay-any-video-file-with-lua/

But for me, in all old threads like this thread:

 

We have a link inside:  "http://leadwerks.com/werkspace/index.php?app=downloads&showfile=89" and when i push it, appears this:

image.thumb.png.f0488a4f64f6f2271d7e22a0d6cdc822.png

And this always happens to me with all the links www.leadwerks.com that now are ok transformed with www.ultraengine.com route.

How can I fix this?

------------------------------------------------------

29 minutes ago, Josh said:

Leadwerks doesn't support video files. Ultimately what you need is a series of texture files and an audio file. Any video file loader will just be doing that behind the scenes. You might as well just use ffmpeg or something to extract a series of images.

Many thanks Josh!!

Yesterday i've found again this thread of @Ttiki very useful...

But I was totally unaware that LUA didn't allow to play video...

Answer that leads me to ask one last question...


Can a Leadwerks game built 100% in LUA run C++ scripts in a mixed way?

Link to comment
Share on other sites

  • 3 weeks later...

The implementation of Theora Video on Leadwerks was written by Niosop a long time ago, even for the 2.x versions of the engine. As practice and a HUGE number of tests and attempts have shown, it works quite unstably and requires significant additions as well as radical solutions to minimize crashes when playing videos (in particular, it requires low quality sound in the video file (96kbps recommended and 128kbps maximum) for more or less stable operation, and video resolutions no higher than 720p at 5000kbps (recommeded 720x576 for 16:9, which, you see, is rather low quality for 2023).
Our first game on Leadwerks, SALVATIONLAND, uses a significantly improved Lua-based version of this implementation, but crashes still occur on certain hardware combinations. We were unable to identify their patterns or fix the C++ code, as Niosop didn't release the source code for the library.
So, yes, I wouldn't recommend using this Theora implementation to ANY users of the engine. It's necessary to write video implementation from scratch, look for ways to do so. We're currently searching and have not yet found a solution.
There was our attempt to attach some ffdshow components to the engine to launch full-screen video separately from the application process. Unfortunately, this caused a large number of problems and was a rather rough.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
39 minutes ago, Gun Man said:

On the topic of video playback, will video be supported natively in Ultra Engine?

I've skimmed through the documentation, but couldn't find anything relating to video.

Not yet but I am open to adding this in the future.

  • Like 2

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

It looks like ffmpeg is probably the easiest way to achieve this.

Exact audio:
https://stackoverflow.com/questions/9913032/how-can-i-extract-audio-from-video-with-ffmpeg

Extract frames:
https://stackoverflow.com/questions/10957412/fastest-way-to-extract-frames-using-ffmpeg

I think that's pretty much it. All that's needed is to wrap it up in some nice easy to use commands.

  • Like 3

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

@Josh, as UltraEngine uses Vulkan you might consider using the Vulkan Video extensions ( researched since 2018 and integrated since 2021 )

https://www.khronos.org/blog/an-introduction-to-vulkan-video

It enables you to decode and encode H264 (mp4) and maybe other formats (don't know exactly) directly on the gpu and use the frames as normal VKImageViews / VKImages and VkBuffers. 

A good sample of the integration is located here: 

https://wickedengine.net/2023/05/07/vulkan-video-decoding/

  • Like 1
  • Upvote 2
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
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...