;

PDA

Click to See Complete Forum and Search --> : Using movie format to load bitmaps?


sinsro
09-04-2007, 06:12 AM
I am making a game which has a serious amount of animated bitmaps. So far I have loaded all frames as individual images, but its clear this approach will result in a monster download as individual PNG files do not compress well for animations at all.

So, I am considering loading FLV files compressed using H264, with an alpha channel (8-bit alpha channels are crucial in my game). This will take care of the size problem.

However, I cannot play FLV files directly, as the game features hundreds of animated sprites at the same time, and decoding the animation from H264 for each one in real time is just too slow.

My idea is to load the movie, then extract individual frames from it as BitmapData objects, with the alpha channel intact.

But, so far, I have not found a way to extract all frames from a FLV movie into BitmapData objects.

Can anyone help?

joshstrike
09-05-2007, 07:49 PM
Just caught this...
that's a serious problem. Much as you might not want to do it, I think you need to create a load structure that will load and parse the PNG files on the fly on an as-needed basis. It doesn't make sense to preload a bunch of FLVs and extract snippets from them, nor do I think it's possible. There are a couple other options, though it might be too late for them; but if you're willing to restructure a little bit, I would definitely suggest you create sprite sheets for each animated character and put them into one or more .swfs in the library, then load them on call, and create a simple class that masks them out and moves the underlying sheet to the coordinates that were called for; you could even use one sprite sheet for multiple animated characters if you're clever about how you lay them out.
If you don't know what I mean by a sprite sheet, this is a sprite sheet of Barney the Purple Dinosaur:
http://sousanator.psparchive.de/Sprite%20Sheets/barney.PNG
This is the way game designers have been doing animated characters since time immemorial and although there aren't a lot of flash coders who do things this way, there also aren't a lot who do big games with lots of 2D characters...

sinsro
09-06-2007, 10:20 AM
Just caught this...
If you don't know what I mean by a sprite sheet, this is a sprite sheet of Barney the Purple Dinosaur:
http://sousanator.psparchive.de/Sprite%20Sheets/barney.PNG
This is the way game designers have been doing animated characters since time immemorial and although there aren't a lot of flash coders who do things this way, there also aren't a lot who do big games with lots of 2D characters...

Thank you for your answer. "Sprite sheets" is a well known technique to me, and I have been a professional game developer for more than a decade now. In fact I already do something similar to avoid multiple http requests, all the individual images are downloaded as one solid file, which I also compress, which saves a huge amount of downloading time as downloading a huge file is faster than downloading 100s of small ones. Unfortunately, the technique does not address the problem stated in the original post.

Perhaps I did not explain the problem in enough detail:

The issue is, I want to achieve compression along the time axis. Basically this means I want to store my animations in a format which only saves the difference between each frame. Individual PNG images, in a sprite sheet or not, does not offer such compression. Typically movie formats are very good at this and achieve significantly smaller files at lossy but high quality (well, depending on the set bitrate).

The ideal scenario would be to compress all frames using a modern MPEG algorithm, which also includes the 8 bit alpha channel, as described in the original post. This is possible using FLV, but the problem is there seem to be no way to extract the individual frames later?

My next thought is to implement my own loader for a movie format, but that surely seem like a lot of wasted energy as there is a fast decoder built into the Flash virtual machine.

To put this into perspective, my game now contains something like 10 megabytes worth of animations after normal compression. Surely too heavy for download, it would kill my server given enough people playing.

Reduced to a proper animation format, the same animations should still look good weighting only a few hundred kilobytes. So, this is my motivation for doing this..

joshstrike
09-06-2007, 07:13 PM
Crazy. Well, I can't help you on the FLV to Sprite question, maybe somebody else can...? I'd love to see it when it's done, anyway. Didn't mean to come off as condescending, I had no idea you were talking about something on such a large scale...