MP3 Compression with Lame and AIR 2.0 by Thibault Imbert

logo-lameIf 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.

Lame MP3 Encoder in AIR 2.0

Download the AIR app here, and make sure you installed the AIR 2 beta runtime.

Comments (15)

  1. maru wrote::

    so cool !
    waiting for an ffmpeg encoder with AIR ! Keep up the good work, dude :)

    Friday, December 18, 2009 at 11:01 am #
  2. fr wrote::

    mmm. So it relies on mac’s lame encoder ? is it installed and accessible on any linux or pc as well ?

    Friday, December 18, 2009 at 12:23 pm #
  3. Tek wrote::

    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 ? :)

    Friday, December 18, 2009 at 12:45 pm #
  4. Thibault Imbert wrote::

    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

    Friday, December 18, 2009 at 2:14 pm #
  5. Thibault Imbert wrote::

    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

    Friday, December 18, 2009 at 3:06 pm #
  6. Tek wrote::

    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.

    Friday, December 18, 2009 at 4:48 pm #
  7. Ogla Sungutay wrote::

    great to see AIR 2 NativeProcess in action. I have so many evil plans with that! :)

    Tuesday, December 22, 2009 at 12:48 am #
  8. Fabio wrote::

    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!

    Sunday, January 24, 2010 at 11:51 am #
  9. Thibault Imbert wrote::

    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

    Sunday, January 24, 2010 at 1:36 pm #
  10. B.K. wrote::

    So now we can build interfaces for basicly any command line apps with AIR?

    Wednesday, February 17, 2010 at 6:31 pm #
  11. Jordan W wrote::

    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

    Saturday, March 6, 2010 at 11:32 am #
  12. Ionel Crisu wrote::

    This is crazy man, thanx!, I will take a look right away.

    Thursday, March 18, 2010 at 10:10 am #
  13. Hugues Frei wrote::

    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 ?

    Thursday, April 22, 2010 at 5:05 pm #
  14. daslicht wrote::

    Cool stuff !
    Do you even get a progression status ?
    Its no longer working with the latest AIR

    Thursday, June 17, 2010 at 10:07 pm #
  15. PG wrote::

    Interesting. I’m going to try using it.

    Tuesday, July 6, 2010 at 2:21 am #

Trackbacks/Pingbacks (4)

  1. Flash platform and more… « dkor on Friday, December 18, 2009 at 2:43 pm

    [...] morning Thibault Imbert posted on the ByteArray.org blog a link to the Lame AIR application. Moreover he brought our attention [...]

     
  2. [...] MP3 Compression with Lame and AIR 2.0 [ by Thibault Imbert ] [...]

     
  3. lame mp3 encoder - StartTags.com on Wednesday, January 27, 2010 at 3:56 pm

    [...] 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 [...]

     
  4. [...] 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. [...]