Recompress your Flash 11 SWFs with LZMA

Flash 11 can load SWFs that have LZMA compression; previously SWF contents were either uncompressed or zlib-compressed.

Since the mxmlc compiler doesn't yet support this compression, and since it was a PITA to compile Tinic Uro's zlib2lzma on anything but Windows (http://blog.kaourantin.net/?p=124), and since no one else seems to have done it... I wrote a Python script to do the conversion. Woot. It only requires that the input SWF be compiled with -swf-version=13 (or higher). It will fail if you feed it an LZMA-compressed SWF -- feel free to fork me on GitHub and fix that.

Usage: python swf2lzma.py in.swf out.swf

Grab the code from: http://github.com/jspiro/swf2lzma


Breakdance McFunkypants said...

Fantastic work! Thank you - your efforts are appreciated.

Will Jordan said...

Thanks very much for this script, it's very much appreciated! I've run across a problem where it doesn't work on a legacy Python 2.4 installation (which is the only version available by default on a CentOS 5.4 virtual machine I'm working with), because the 'bytearray' global isn't available until a later Python version. Any ideas on how to adjust this script to work without this more recent feature, or is this particularly necessary?

Jono Spiro said...

Unfortunately I don't know how to modify it to work with earlier versions of Python. But you should fork me on github if you come up with one!

I am not a Pythonista so I was just working with what I could find on the nets :)

Will Jordan said...

Spent a bit of time with it this morning and got something that works in Python 2.4. Sent you a pull request on GitHub~

SARANG said...

I am using Python 3.3.2

I tried to execute command

python swf2lzma.py Main.swf outputMain.swf

got following error:

File "swf2lzma.py", line 50
print 'compression: %d%%' % round(100 - (100.0 * zsize / swf_size))
SyntaxError: invalid syntax

Please help on this