A new project requires using Red5 and Xuggler on a CentOS virtual host. Unfortunately, setting up both Xuggler and Red5 can be a bear on CentOS, because the default installation doesn’t come with Java. So, I’ve put together a tutorial that should help you out if you’re trying to setup a Red5 system with Xuggler.
Step 1: Setup Java
CentOS will use the openJDK packages if you try to install java via YUM, but unfortunately, these packages have caused problems for a lot of users trying to install Red5. I recommend using the Sun binaries, which now seem to work fine for CentOS. First, you’ll want to download the most current JDK (note: it must be the JDK rather than JRE package) rpm binary package from this site:
$ cd /usr/src
$ wget $long_link_from_java_download_page$
Once its downloaded, make sure the filename looks something like ‘jre-xxxx-linux-i586-rpm.bin‘. Next, make sure the binary is executable, and run it:
$ chmod a+x jre-6u17-linux-i586-rpm.bin
$ ./jre-6u17-linux-i586-rpm.bin
You’ll get a license agreement page, so hit the space bar until you get to the bottom, and type ‘yes’ to agree. Next, you’ll need to run the resulting rpm package:
$ rpm -i jre-6u17-linux-i586.rpm
Now, confirm that java has been installed correctly to /usr/local by running the ‘java -version’ command:
$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)
$
If the command runs successfully, you’re all done with Step 1.
Step 2: Get ANT
Apache ANT is a build system commonly used for java projects. ANT is required by both Red5 and Xuggler, so we’ll go ahead and get it installed. The setup is pretty easy; first, download and extract the latest ANT binary:
$ cd /usr/src
$ wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz
$ tar -xzf apache-ant-1.7.1-bin.tar.gz
$ mv apache-ant-1.7.1-bin /usr/local/ant
Now, you need to setup the ANT_HOME environment variable:
$ export ANT_HOME=/usr/local/ant
$ export PATH=$PATH:/usr/local/ant/bin
Step 3: Setup Xuggler
The best way to get Xuggler is to download it via the current SVN trunk:
$ cd /usr/src
$ svn checkout http://xuggle.googlecode.com/svn/trunk/java/xuggle-xuggler xuggle-xuggler
Once everything has been checked out (which can take quite a while), move into the xuggle-xuggler directory and set the appropriate environment variables:
$ cd /usr/src/xuggle-xuggler
$ export XUGGLE_HOME=/usr/local
$ export PATH=$XUGGLE_HOME/bin:$PATH
$ export LD_LIBRARY_PATH=$XUGGLE_HOME/lib:$LD_LIBRARY_PATH
Next, begin the build by running:
$ ant run-tests
This will make all the native and java binaries and then run the appropriate unit tests on each. This can take a while (10 minutes on my server), so be patient. Ideally, all the tests should pass, but sometimes I’ve had certain MP3 tests fail. If you don’t plan on using the MP3 transcoding features of Xuggler, you can ignore these errors. Next, install Xuggler:
$ sudo ant install
If everything went well, you should see a bunch of print outs indicating a successful install.
Step 4: Install Red5
Like Xuggler, the best place to get Red5 is the current SVN trunk:
$ cd /usr/local
$ svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
Next, use ANT to build and install Red5:
$ ant prepare
$ ant dist
$ cp -r dist/conf .
If everything went well, Red5 should be installed and configured. You can test your install by starting the server:
$ ./red5.sh
and visiting ‘http://yourserveraddres:5080/‘. If you get the screenshot below, you are good to go with Red5.
Step 5: Copy Xuggler to Red5
For Red5 to use the Xuggler library, you have to copy a compiled Jar to the red5/lib directory:
$ cp /usr/src/xuggle-xuggler/dist/lib/xuggle-xuggler.jar /usr/local/red5/lib
And with that, you should be all set to go! Just copy your Red5 app into the webapps directory and you’re ready to do some cool stuff with video.