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.

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