Tutorial: How to use Videos in Monkey

Monkey Archive Forums/Monkey Projects/Tutorial: How to use Videos in Monkey

time-killer-games(Posted 2012) [#1]
I went thru a lot of trouble trying to figure out how to use videos in monkey, this is the best I could come up with. I really hope it helps some people! :D

Monkey Target Compatability (tested):
-BlitzMax - Works on MonkeyMax
-GLFW - Compiles! (I need testers because my graphics card needs an update)
-XNA - Compiles! (I need testers because my graphics card needs an update) You can't use strips for this target because XNA has a limit on strip resolutions. Small video resolutions and short videos work, this tutorial allows you to use videos in XNA regardless of the resolution limit, because the video frames are stored as seperate image files.
-Android - need testers!
-iOS - need testers!
-Html5 - Doesn't work in HTML5 (though it can work using strips, instead of hundreds of seperate images as used in my example)
-Flash - If a short video, yes, but iffy. Flash's current version of Flex compiler doesn't like huge image resolutions whether they are in a strip or seperate files used in the same project.

Compatability Notes (tested):
this tutorial doesn't work with the FLASH or HTML5 targets. Html5 gives issues with the video such as showing the video in the wrong frame order, rendering it not usable. In FLASH it DOES work, BUT ONLY for videos that have a very small frame count. If your video has over 500 frames there is a good chance your game won't compile and will give you a "Java Heap Space" Error (is this a monkey bug I smell?).

STEP 1: So basically what I use for videos in monkey, take any video format you name it and convert it to AVI (and WAV/MP3/OGG as well if there is audio used in the vid), using one of these free online file converter websites:

--> http:www//www.online-convert.com - fast, free, upload and download files instantly from a url or on your computer, it costs money if your file is too big. Most format convering options, even video/audio editing options i.e. change resolution, normalize, etc.

--> http://www.zamzar.com - same as the first converter only its free no matter the size; it requires giving out your personal email, which the download link to your converted files are sent to you by email. It might take longer than online-convert.com

--> http://www.youconvertit.com/ConvertFiles.aspx - the same as zmazar with different format options i.e. swf 2 avi

STEP 2:Download my open source example, which is available here:
--> http://dl.dropbox.com/u/79893663/MonkeyVideoExample.zip
The example comes with a free AVI 2 BMP frames converter, you will have to convert the BMPs to PNG by yourself using whatever free batch image converter or one of the converter sites mentioned above, for single files, file after file. Edit the example to use your own video frames! Doen't forget to also convert the video's audio (if any) for your video to have animation AND sound.

Boring Legality Info:

The code in the example is all yours, but on that note all media in it other than the monkey code is 100% my artwork media and property. Do not redistribute this tutorial and/or its contained media under any situation. You may only share or modify the SleepingDisorder.monkey file, but NOT the SleepingDisorder.data folder, any of its contained files, you can't with the vid.avi in the downloaded zip either unless you replace that with a video that you made yourself. The AVI frame extractor dll I did NOT make; It is not my property; it was made by a user at the GameMakerCommunity forums: gmc.yoyogames.com. His screenname is h0bbel, you can find him here: http://gmc.yoyogames.com/index.php?showuser=46246 The converter is made in Game Maker, it can only convert AVI files because of that dll, The exe just executes dll's external functions. Game Maker is currently a product owned and sold by YoYoGames Ltd. PS - Monkey is sooooOooo much better than GaneMaker:Studio and GM:Standard for windows and mac :P. Gotta love Monkey and BlitzMax! :D


ErikT(Posted 2012) [#2]
Cool! I'll try this out on my wildfire phone tomorrow :D


Beaker(Posted 2012) [#3]
How does it work exactly?


NoOdle(Posted 2012) [#4]
I believe it displays a sequence static images (ala sprite frame animation) in time with a sound file to mimic video capability although I only quickly read the description so I might have misunderstood.


time-killer-games(Posted 2012) [#5]
^That's what I meant. :) The only difference is loading the images seperately instead of strips, because strips can't be but so big in most the targets.

For using the video frame extractor; you can edit the text file found in its directory. It reads that text file for determining what AVI file to extract frames from and what the file name of each frame should be called.