If there is one thing that I love in AIR 2, it is the Native Processes. It allows you to interact with any native application on the client. The really cool thing is that such an app can be embedded within the AIR application which can be bundled as a .dmg file for MacOS and .exe for Windows. So many projects can benefit from that, WiiFlash would be one of those. I am working right now on a PDF Reader in AIR 2.0 cross-platform, around 5mb handling PDF's up to version 1.7, a C PDF rendering engine is bundled, does all the heavy work and output bitmaps to AIR. But one of the funny thing I wanted to achieve was MP3 compression.
So here is a demo using the new Microphone API, AS3 code saves the raw samples coming from the mic to a WAV buffer file, then, the command line MP3 Lame Encoder which is bundled into the AIR app does all the MP3 compression for you. Files are then saved on your desktop. It's an early demo version, do not pay attention to the crappy code, I will add more options to it and visually tune it.
It works very nicely and I was pretty impressed by how simple it was to communicate with the command line app, through the NativeProcessStartupInfo class. A complete AS3 wrapper could be built to use all the lame encoder features. Kudos to the AIR team for this crazy feature.

Download the AIR app here, and make sure you installed the AIR 2 beta runtime.
Comments (15)
so cool !
waiting for an ffmpeg encoder with AIR ! Keep up the good work, dude
mmm. So it relies on mac’s lame encoder ? is it installed and accessible on any linux or pc as well ?
As I know you, I’m sure you already have looked into it, is there any way to port this to the web with Alchemy ?
Hi fr,
Each AIR app (.dmg or .exe) contains the appropriate version of Lame encoder (mac or pc). For linux, I have to take a look
Thibault
Hi Tek,
Yes that would be possible to port that to Alchemy but I think, it would be hard to encode big files this is the problem that Bernard Visscher had : http://blog.debit.nl/?p=67
Thibault
It seems a hard job to optimize it though. With the new Microphone capture feature that’ll (I hope) come a day on the web Flash Player, it would have been the perfect combination to create interesting new projects.
great to see AIR 2 NativeProcess in action. I have so many evil plans with that!
I found it very interesting.
Question: can I include in a flash project? I would to make an application that record from microphone and save an mp3 file.
Thanks!
Hi Fabio,
Unfortunately, Native Processes are not available in Flash Player only in AIR, so outside the browser. However, with Alchemy you can try doing runtime MP3 compression. However, you won’t be able to encode large files in a high bitrate, this would require imho too much cpu cycles for the Flash Player.
best,
Thibault
So now we can build interfaces for basicly any command line apps with AIR?
I guess it was only a matter of time till someone made this, I’m glad it was you T. Too bad in the end it’s just another GUI for LAME. Now LAME in HaXe, that would be nice to see – get to use that fast memory. It’d be nice if you and Nicolas had a mating, I’m sure we’d see “sparks” fly. haha
This is crazy man, thanx!, I will take a look right away.
Good idea for the PDF reader with AIR but why not a PDF to XFL with all text, images and fonts attributes and links for each page ?
Cool stuff !
Do you even get a progression status ?
Its no longer working with the latest AIR
Interesting. I’m going to try using it.
Trackbacks/Pingbacks (4)
[...] morning Thibault Imbert posted on the ByteArray.org blog a link to the Lame AIR application. Moreover he brought our attention [...]
[...] MP3 Compression with Lame and AIR 2.0 [ by Thibault Imbert ] [...]
[...] application. … The ability to use my iTunes and have a LAME encoder all at the same time. …MP3 Compression with Lame and AIR 2.0 [ by ...So here is a demo using the new Microphone API, AS3 code saves the raw samples coming from the mic [...]
[...] I always had in mind to try this out, and with advent of Air 2.0 and Native Process, i had finally the chance to realize this. (like usual someone did it before me .. so i must quote Thibault that basically use the same strategy on AS3 Lame Project. [...]