Flex Ant flexTasks, Manifests and Library Includes

I recently was working on a framework project where one of our front-end developers had written several UI components in Flash Profressional and compiled them into a SWC for me to leverage in an ActionScript project in Flash Builder.  Aside from the compiled SWF, we also had to deliver a SWC to third-party vendors that were developing content against our framework.  The SWC had to include a small subset of event classes from the ActionScript project along with the UI components library from my front-end dev.

The first step was to leverage the flexTasks Ant library included with the Flex SDK to use the compc task.  This is simple enough by specifying the classpath to the flexTasks.jar.  The next step was to create a manifest file specifying the classes in my ActionScript project that should be included in the SWC.  This involves defining a namespace for the manifest, then including the namespace in the compc task.  The final step was including the externally compiled SWC for the UI components.  As simple as it turned out to be, this was a much more difficult task to accomplish, primarily because of the lack of good documentation and examples from Adobe.  

Below are examples of the manifest and ant builder files I ended up using for the project.  Keep in mind some variables Ant variables are defined outside of the builder file itself as Ant properties in the builder launch configuration setup in Eclipse.

manifest.xml

<?xml version="1.0"?> 
<componentPackage> 
    <component class="com.genuinejd.events.NavEvent"/> 
    <component class="com.genuinejd.events.LayoutEvent"/> 
    <component class="com.genuinejd.events.ReferenceEvent"/> 
    <component class="com.genuinejd.events.ModalEvent"/> 
</componentPackage>

builder.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="SWC Builder" basedir=".">   
    <property name="SOURCE_DIR" value="${basedir}/src" />
    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 
    <target name="main"> 
        <compc output="${OUTPUT_DIR}/Lib.swc" >
            <source-path path-element="${SOURCE_DIR}/"/> 
            <namespace uri="http://genuinejd.com/2011" manifest="${basedir}/manifest.xml" />
            <include-namespaces>http://genuinejd.com/2011</include-namespaces>
         <compiler.include-libraries dir="${SOURCE_DIR}/../libs" append="true">
             <include name="UI_controls.swc" />
            </compiler.include-libraries>
        </compc> 
    </target> 
    <target name="clean"> 
        <delete> 
            <fileset dir="${OUTPUT_DIR}" includes="Lib.swc"/> 
        </delete> 
    </target>
</project>

 

Building FFmpeg for Windows on Linux - Part 2 - Setting Up the Build Environment and Extra Libraries

In the last article, I explained how to install Ubuntu 10.10 64-bit using the VirtualBox software and get the instance of Ubuntu all up to date.  This article will focus on getting our build environment set up for compiling FFmpeg.  This part is arguably the most difficult as it involves not only setting up the compilation tools, but also cross-compiling additional libraries to be used with FFmpeg that are not included by default.  If you using the same exact software and versions as described in my introduction, this should be as easy as following directions step by step.  Let's get started...

 

  1. Open a terminal window in the Ubuntu guest system (Applications -> Accessories -> Terminal).  Most of the work will be performed here for the rest of this series.
  2. Most of the hard work has been done for us by a gentleman who maintains the site at arrozcru.org.  To use his libraries for cross-compiling, download and import his gpg key and update your packages list
    • Download and import the gpg key to your system
      ~$ gpg --keyserver www.keyserver.net --recv-key 0x25E635F9
      ~$ gpg --export --armor 0x25E635F9 | sudo apt-key add -
    • Add the apt repositories to your sources.list file
      ~$ echo "deb http://apt.arrozcru.org ./" | sudo tee -a /etc/apt/sources.list
      ~$ echo "deb-src http://apt.arrozcru.org ./" | sudo tee -a /etc/apt/sources.list
    • Update your package list
      ~$ sudo apt-get update
  3. Set up and install the cross toolchain.  If you are working with a version of Ubuntu other than 10.10 or the 32-bit version, be sure to follow Option 1 to recompile the toolchain.  If you are using Ubuntu 10.10 64-bit, be sure to follow Option 2.
    • Option 1
      1. Create cross toolchain directory and install dev tools
        ~$ mkdir cross
        ~$ cd cross
        ~/cross$ sudo apt-get install dpkg-dev debhelper autotools-dev libmpfr-dev libgmp3-dev libppl0.10-dev libcloog-ppl-dev libmpc-dev
      2. Install the mingw api and runtime
        ~/cross$ sudo apt-get install mingw32-w32api mingw32-runtime
      3. Recompile and deploy mingw binutils
        ~/cross$ apt-get source --compile mingw32-binutils
        [lots of output not shown here]
        ~/cross$ sudo dpkg -i mingw32-binutils_*.deb
      4. Recompile and deploy mingw gcc 4.4
        ~/cross$ apt-get source --compile mingw32-gcc-4.4
        [lots of output not shown here]
        ~/cross$ sudo dpkg -i mingw32-gcc-4.4_*.deb
      5. Install mingw binutils and gcc
        ~/cross$ sudo apt-get install mingw32-binutils mingw32-gcc-4.4
    • Option 2
      ~$ sudo apt-get install mingw32-w32api mingw32-runtime mingw32-gcc-4.4 mingw32-binutils
  4. Patch the cross toolchain with Arrozcru's patches
    • Install patch to patch the cross toolchain
      ~$ sudo apt-get install patch
    • Download patches from Arrozcru
      ~$ mkdir mingw32-patches
      ~$ cd mingw32-patches
      ~/mingw32-patches$ wget http://fate.arrozcru.org/mingw32/patches/tempnam.diff
      ~/mingw32-patches$ wget http://fate.arrozcru.org/mingw32/patches/strcasecmp.diff
      ~/mingw32-patches$ wget http://fate.arrozcru.org/mingw32/patches/nomt.diff
    • Patch the cross toolchain
      ~/mingw32-patches$ cd /usr/i686-mingw32
      /usr/i686-mingw32$ sudo patch -p2 < /home/corpapps/mingw32-patches/tempnam.diff
      /usr/i686-mingw32$ sudo patch -p2 < /home/corpapps/mingw32-patches/strcasecmp.diff
      /usr/i686-mingw32$ sudo patch -p2 < /home/corpapps/mingw32-patches/nomt.diff
  5. Compile extra libs as needed
    • Get and build libfaac
      1. Download and extract faac-1.28.tar.bz2
        ~$ wget http://downloads.sourceforge.net/faac/faac-1.28.tar.bz2
        ~$ tar -xvf faac-1.28.tar.bz2
      2. Configure and build libfaac
        ~$ cd faac-1.28
        ~/faac-1.28$ ./configure --host=i686-mingw32 --prefix=/usr/i686-mingw32 --enable-static --disable-shared --with-mp4v2=no
        ~/faac-1.28$ make
        [lots of output not included here]
        ~/faac-1.28$ sudo make install
  6. Install extra libs from Arrozcru's apt repository
    • You will need to determine what libraries to install using
      ~$ apt-cache search mingw32-
    • Install each library one at a time using sudo apt-get install mingw32-<pkg-name> or copy/paste the string below
      ~$ sudo apt-get install mingw32-ocaml mingw32-libmp3lame mingw32-bzip2 mingw32-libcloog-ppl mingw32-libsdl mingw32-libppl mingw32-libx264 mingw32-libopenjpeg mingw32-polarssl mingw32-libmpc mingw32-libfaad2 mingw32-librtmp mingw32-libtheora mingw32-libxvid mingw32-libmpfr mingw32-openssl mingw32-libgmp mingw32-libschroedinger mingw32-liborc mingw32-libvorbis mingw32-libogg mingw32-libspeex mingw32-pthreads mingw32-directx mingw32-zlib mingw32-libgsm mingw32-liboil mingw32-libopencore-amr
That's it!  The hardest part of cross-compiling FFmpeg for Windows is in the setup; getting the cross-compiler and the libraries ready.  One thing to notes is that several times when trying to download the gpg key for arrozcru, the keyserver timed out.  I did have luck removing the keyserver argument and attempting to download it with the following command
~$ gpg --recv-key 0x25E635F9
In the next and final article, I will outline how to setup the directories we'll use for downloading the FFmpeg source, configuring and building it.

 

Building FFmpeg for Windows on Linux - Part 1 - Setting Up the Virtual Environment

The first part of this tutorial will cover setting up the virtual instance of Ubuntu 10.10 on a Windows 7 64-bit laptop using VirtualBox.  The steps below will outline the entire process to get your virtual evironment ready to compile FFmpeg.

  1. Download and install VirtualBox for Windows hosts
    http://www.virtualbox.org/wiki/Downloads
  2. Download Ubuntu Desktop Edition 10.10 64-bit ISO
    http://www.ubuntu.com/desktop/get-ubuntu/download
  3. Create a new VirtualBox virtual machine and install Ubuntu from the downloaded ISO
    • VM Name and OS Type
      • Name: Ubuntu 10.10
      • Operating System: Linux
      • Version: Ubuntu (64 bit)
    • Memory: 512 MB (Default) - I increased this to speed up the process a bit.  If you have more RAM to allocate to this VM, go ahead and do so.
    • Virtual Hard Disk
      • Boot Hard Disk: Checked
      • Create new hard disk: Selected
        • Storage Type: Dynamically expanding storage
        • Virtual Disk Location: Default
        • Virtual Disk Size: 8.00 GB (at least 6 GB is recommended)
    • Add the Ubuntu ISO as a CD Drive
      1. Select the newly created VM and click Settings
      2. In the Settings dialog, select Storage from the left side menu
      3. In the Storage Tree, select Empty under IDE Controller, then click the folder icon to the right of the CD/DVD Device drop-down to open the Virtual Media Manager
      4. Click the Add button to add the Ubuntu 10.10 ISO that you downloaded above
      5. Select the ISO that you just added and click the Select button
      6. Verify that the ISO has been added to the CD/DVD Device and click the OK button to close the Settings dialog and accept the changes.
    • Start the VM and follow the Ubuntu installation instructions
      1. When Ubuntu first loads from the CD (ISO), it will prompt you to either Try Ubuntu or Install.  Select Install.
      2. Preparing to install Ubuntu
        • Download updates while installing: Unchecked.  We will install updates after the installation
        • Install this third-party software: Unchecked.  This is not necessary for our purposes.
      3. Allocate drive space: Erase and use the entire disk (use defaults on next screen [select drive])
      4. Click the Install Now button
      5. During installation, select the appropriate options for timezone and keyboard layout
      6. Who are you? Create a username and password, be sure to either write down this information or remember it so you can login to Ubuntu later.
      7. Sit back and wait for Ubuntu to finish installing, it takes about 10-15 minutes depending on the allocated resources of the VM.
      8. Once the installation has finished, you'll be prompted to restart.  Go ahead and restart, and if it prompts you to remove installation media, do so by opening the menu Devices -> CD/DVD Devices and click Ubuntu 10.10 ISO to un-check it.
      9. After restart, login to Ubuntu with the username/password entered during installation
  4. Run all Ubuntu updates, either via Update Manager or apt-get.  Either option will take some time to download and install updates.  Get and install updates until there are no updates left.
    • Update Manager
      1. Open the Update Manager in Ubuntu under the System -> Administration menu (it may open automatically after having been logged in for a minute)
      2. When the Update Manager opens, click the Install Updates button and enter your password when prompted to Authenticate
      3. Wait for the updates to install, this may take several minutes
      4. After the updates are installed, restart and log back in
    • apt-get
      Open a terminal (Applications -> Accessories -> Terminal) and enter the following commands

      ~$ sudo apt-get update
      ~$ (output removed)
      ~$ sudo apt-get upgrade
      ~$ (output removed)
  5. Install VM Additions - this will make it a little easier to interact with your guest operating system
    1. In the VM host window, select Devices -> Install Guest Additions... to "insert" the VM Additions Cd into the VM
    2. Mount the CD in the guest VM by selecting Places -> VBOXADDITIONS_x.x.xx_xxxxx
    3. This should cause a "Places" window to open which indicates "The media has been detected as 'UNIX software'.  Click the Open Autorun Prompt, then click the Run button when prompted to confirm
    4. Enter your password if prompted to perform administrative tasks and click the OK button
    5. VM addittions will open a new terminal window and be uncompressed, built and installed
    6. When it is finished, press Return (Enter) to close the build window
    7. Restart to finish enabling VM additions
    8. After restarting and logging back in, you can "eject" the VM additions CD by right-clicking the desktop icon, and selecting Eject, then under the VM host window, select Devices -> CD/DVD -> VBoxGuestAdditions.iso to un-check the ISO.
Your virtual instance of Ubuntu has now been installed and updated.  At this point, you can do with it what you like.  In the next part of this series, I will cover the steps needed to set up the build environment and all required libraries for FFmpeg.

Building FFmpeg for Windows on Linux - Introduction

At work, we deal with a lot of video production.  Those videos need to constantly be reviewed and approved by various legal staff.  To support this workflow, we decided to implement a video reviewing and management application.  The web application was the easy part.  Our technology stack was based around a lot of Adobe products, so we decided on Flash Media Server for our streaming infrastructure.  The difficult part was getting the video files in a format to stream using our streaming technology.  Encoding solutions that could scale easily were expensive.  So after evaluating several options, we decided to write our own solution to handle video encoding.

At first we started using an automated binary build of FFmpeg from http://ffmpeg.arrozcru.org/ and just wrapped some C# code around it (thanks to a suggestion from my brother-in-law).  This worked fine in the beginning, but as our format and encoding option needs changed, we could no longer rely on the generic automated builds.  We needed to be able to build our own binary of FFmpeg with specific libraries included.  Additionally, at the time of this writing, that site no longer hosts the automated builds.

This ended up being a far more complicated task than I imagined.  There was some documentation in various places, but nothing that specifically walked through the process step-by-step for someone unfamiliar with the process.  Once I was finally able to successfully compile and build FFmpeg, I decided I needed to document the entire procedure.  This series of blog posts will attempt to document and identify the entire process I went through to accomplish this.  Some steps may seem obvious, but I will include information for those that may have no knowledge of compiling and building software such as FFmpeg.

This process is written based on the following specifications:

  • Dell Latitude E6500 Intel C ore 2 Duo P8700 2.54 GHz 4.00 GB RAM
  • Windows 7 Professional 64-bit (using a 32-bit OS should be fine, but you will need to recompile the cross toolchain)
  • Oracle VM VirtualBox Version 3.2.10 r66523 (http://www.virtualbox.org/)
  • Ubuntu 10.10 64-bit (http://www.ubuntu.com/)

Stay tuned for the first set of details on setting up the virtual environment using VirtualBox and Ubuntu.

Cr-48 Chrome OS Beta Update 0.10.156.46

I was lucky enough to receive a Cr-48 just before Christmas (thanks Santa!).  I don't do anything really crazy with it.  You know, email, surfing, the occasional Google Docs editing, etc.  Having the 3G has come in very handy, though.  Anyway, I just got the Beta channel update for 0.10.156.46, which includes an update to Google Chrome 10.0.648.116.  So far, it sounds like mostly bug fixes, none of which I have experienced.  After the last update, I noticed the startup time and general usage seemed to slow down a bit.  I'm hoping I'll see a little performance boost.

Here's the post regarding this update: http://googlechromereleases.blogspot.com/2011/03/chrome-os-beta-channel-update.html

Additionally, I recently turned on 2-step verification security for my Google account.  So far so good.  I do feel a bit better knowing there's an extra layer of security around my account.  That's all fine and good, however, on my Cr-48, I was seeing a Sync Error and my Chrome bookmarks and plugins weren't syncing.  Pressing the button that was supposed to let me enter a password did nothing.

After this update, I was able to correct the issue by opening Settings -> Personal Stuff and selecting to sign-in.  After entering my password, I had to generate an application specific password, and I was good to go!

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. genuinejd.com