What’s wrong with MNG?

Recently, I wanted to make a simple animation to put on a webpage. I have a background image and a rendered 3D animation which should be on top of that.

When it comes to lossless image compression, PNG is my all-time favorite. It has layer support, full transparency, lossless non-patented compression, open format, … So the PNG-derived MNG would be a logical choice for animation, right? Wrong! 🙂 Almost none of the current browsers support it out of the box! Mozilla supported it for some time, but gave up due to bloated implementation. Konqueror is the only one supporting MNG! Can you believe that? 😕 Maybe you can, if you see the popularity of Flash. But what if you just want a simple animation? Is the loading of a full flash player justified for a simple animation? And why prefer a closed proprietary format if there are open ones? So I went on a quest for better formats. 🙂

The only as good alternative I could think of is SVG. I remember PNG taking some time before it was accepted. MNG has taken its time but still doesn’t seem accepted. I think SVG has a better chance to get accepted, but is still just a little bit too new. I had a look at animated SVG but my first impression was that it wasn’t that well suited for my purpose of handling prerendered images, but rather for real vector graphics.

So there I was, back at GIF. I contemplated that GIF, after all, wasn’t patented anymore (I know, not GIF itself, but the compression algo in it), so I could forgive myself using it. 😉 So how to encode a bunch of frames into an animated gif? Simple. Just open your favorite shell with ImageMagick support and type something like:

convert *.png test.gif

You can define a transparent color, but if your input is already PNG, there’s no need to specify that of course. I tried several commands from premerging the background to scaling to translating until I got stuck at the latter. Somehow the translation didn’t work… I decided it was getting too clumpsy anyway, so I burned my foreground into the background in the Blender phase, since this was the first thing I did anyhow before merging into GIF. Btw, I found out, Blender has about 4 ways to achieve this same result. 🙂

But… when I finally got the result, I regretted my choice for GIF a bit.. Thinking of a small band user like my brother, ~280KB for a simple 30 frames animation is a bit too much.. 😉 I knew the GIF format would be inefficient, but still hoped for a good result. It’s obvious that the background storage is inefficient (unless someone can tell my that GIF has layer support?).

So, just to know the difference with flash 😉 I searched the net for a way to generate a flash movie with open source tools only. The solution came in the form of swftools. Swftools provides a (questionable?) script language to script your animation. I have no idea if it is a known scripting language as I don’t know anything about flash. 😉 Anyhow, I have rendered files like 0001.png, 0002.png, etc so it would need some rather repetitive work to create that script (I didn’t find any way to define loops in the script language). For some reason I judged it was overkill to write a program in C, java or C# just for generating a script, so I deemed a scripting language much more adequate for the job. Let’s see, which scripting language then.. 🙂 Windows shell script? not familiar enough with. I did some Perl a while ago, but found out I didn’t install it yet on this PC. Mmm, what’s installed.. Python?! But without IDE. Oh well, everyone says it’s so easy, right? 😉 After some fumbling around to get the formatted strings working in file output, I finally came up with a script that does the job. 🙂

I’ll post it here in case some Python guru feels the need to educate a noob (meaning, comments welcome ;)):

outputfile=open('makesc.out', 'w')
for i in range(1,30):
num = str(i);
outputfile.write(".frame "+num+'n');
outputfile.write('t.png frame'+num+' "'+num.zfill(4)+'.png"n');
outputfile.write('t.put frame'+num+' x=65 y=10n');
outputfile.close();

Does anyone know a great Python reference? Like CHM style, with index, full text search and stuff..

Okay, so having a swftools script, I finally get a flash version of my animation. From 270 to 69KB, not bad…
I’ll guess I have to accept the fact that Flash is everywhere and browser are optimized for it anyhow (tell me that’s true ;)).

I’m still interested in alternatives for web animation formats.. And does anyone know how SWFTools perform in comparison with the commercial Adobe/Macromedia tools?

2 thoughts on “What’s wrong with MNG?”

  1. not bad, think the difference in filesize was likely mostly JPEG compression — usually going vector will cut down the size dramatically. I think with a little tweaking in this case size could still be halved.

    I’m not sure about SWFTools but in terms of open source tools to generate Flash content you could look at swfmill and MTASC that do a wonderful job.

    http://www.osflash.org/swfmill/
    http://www.osflash.org/mtasc/

    Although not open source the SWF and FLV specifications (Flash video as seen on sites like youtube, myspace etc.) are available as an SDK. The license agreement does limit the developer to only use it for creating Flash content, not playing it back.

    I’m a bit ambiguous about an open source Flash player, it sounds like a great idea but I do see Adobe’s point that it could do serious harm if there are multiple versions of the player floating around the web and we’ve no longer got certainty of content running reliably across different systems and browsers.

    Personally I’ve promoted going with a runtime extensibility layer for the Flash player. This addresses some of the concerns people have about including certain functionality while maintaining a single consistent core player that is under central QA control.

    There is in fact a project going on creating an open source Flash Player supported by the Free Software Association.

    http://www.gnu.org/software/gnash/

    Haven’t heard an official response to it yet, but for the reason I mentioned above I believe Adobe will try to enforce their IP on this.

    Think they do recognise the need for opening up formats and have seen some examples of them slowly going in that direction, embracing more liberal licenses such as creative commons and the labs.adobe.com initiative.

    There is a free SDK for compiling to the latest Flash Player release and know of some other projects coming up that will be freely available to developers.

    Also worth mentioning is the effort to port a new version of the Flash Player to Linux which has become a bit of a community effort with engineers blogging about their progress and solliciting input from the community.

    http://blogs.adobe.com/penguin.swf/

  2. hmm, some posts to catch up… (what are holidays good for? :-))

    indeed, png is awesome…, but transparency in png is not handled well by internet exploder…

    and about the python-reference, I once came across http://www.diveintopython.org/
    (Somebody recommended this link, but I don’t know where I’ve seen it…)

Leave a Reply to andrasj Cancel reply

Your email address will not be published. Required fields are marked *