Installing Cent OS 5.5 on EC2 with the Cent OS 5.5 Kernel

Amazon recently introduced the ability to boot a custom kernel using pv-grub on EC2. This opens the door for all kinds of interesting ideas that I've been thinking about for a while, like seeing if I can boot right into a web server and skip all that extra junk that comes with Linux distributions, but that is just me. The main door it is going to open for most people interested in EC2 will be the ability to upgrade the kernel that comes with their distribution. That brings us to how to install Cent OS 5.5 on EC2 and use the kernel that is part of the distribution.

For those who might just be interested in booting a custom kernel using EC2 pv-grub I will try to produce a few more posts with more details on that but for now here are the main things to know:

  • The pv-grup kernels named with hd00 will look on the first partition of the registered device in the /boot/boot/grub directory for a menu.lst file. Use this type of kernel if you create want to use a partitioned disk.
  • The pv-grup kernels named with hd0 will look on the registered device in the /boot/grub directory for a menu.lst file. Use this type of kernel if you don't have a partition on your disk.
  • You won't get anything meaningful back from the boot attempt if your grub menu.lst file is in the wrong place or is not valid. See the end of the post for what a pv-grub error message looks like and some tips on what to do if you see it.
  • The kernel you use does matter but the current mainline Linux kernel (2.6.35) contains everything you need except for a small change to turn off XSAVE. The main thing to know is that not every distribution may have made the change needed to work on EC2.
  • I have tried non-Linux kernels to no avail. See the end of the post for a little more information.

Read More »

Posted in system administration | Tagged , , , | 24 Comments

Compiling WebM into FFMpeg for Windows

I have updated this post with a newer version of the VP8 patches to FFMpeg and support for libvorbis instead of the built in vorbis support.

Google has released source for the VP8 codec as the WebM project. The WebM project will be an open alternative in the HTML5 video tag codec space and being backed by Google, who will use it for YouTube, will give it a fighting chance. WebM is starting to be integrated into FFMpeg but there are still some patches that need to be applied. While there are some guides to how to build FFMpeg for Linux with VP8 WebM support I wanted to get it compiled for Windows.

First off this won't be done using a Windows install but instead using Virtual Box with a fresh install of Ubuntu 10.04 desktop. It is just faster and easier that way. So go ahead and grab Virtual Box and get Ubuntu installed on it before you continue.

Read More »

Posted in meta | Tagged , , , | 12 Comments

Upgrade to Fedora 13 from Fedora 12

After a week delay Fedora 13 has been released and it is time to upgrade of course. As always there are a decent number of features in this release but here are a few that stand out to me:

  • boot.fedoraproject.org – A small bootable image to start the install from.
  • IntelliJ IDEA – IntelliJ IDEA community edition. I'm glad to see my favorite IDE make it in along with Netbeans and Eclipse even if it is just the stripped down version.
  • Python 3 – Running along side Python 2.
  • Nouveau DisplayPort – Support for NVIDIA cards with a DisplayPort.
  • Radeon DisplayPort – Support for Radeon cards with a DisplayPort.
  • NetworkManager Command Line – A command line interface for NetworkManager. As much as I find myself hating NetworkManager maybe this will help.
  • Gnome 2.30 – The latest stable version of Gnome.
  • KDE 4.4 – The latest stable version of KDE.

Check out the Fedora 13 feature list for all the major features in this release.

Read More »

Posted in system administration | Tagged , | Leave a comment

Faceted Search With Sphinx

I decided to use the Sphinx search engine for the GeeQe iPhone app I build last year because it was fast and had a very small memory footprint. Recently I wanted to experiment with a search interface that had facets and wondered if I would need to move away from Sphinx to something like Solr. As it turns out Sphinx can do faceted search almost as well as Solr can. The first half of what follows contains instructions on how to get Sphinx ready for faceted searches. If you are familiar with setting up Sphinx and already have data indexed by Sphinx you may find it better to skip to the second half after reading the intro to faceted search.

You have almost certainly seen faceted searching or faceted browsing already. A lot of online retailers now use facets in their online stores. Here are a few examples:

Read More »

Posted in programming | Tagged , | 1 Comment

How to Create iPad Formatted Videos Using HandBrake or FFMpeg

This is for those who may want to load a video onto their iPad with iTunes that isn't in the correct format. I needed to do this because I was trying to put an iTunes University video on my iPad a couple days ago and iTunes complained that it wasn't in the correct format for the iPad. I'm not sure exactly how that could be but I decided to take the opportunity to see if I could use HandBrake to easily convert it to an iPad friendly format. There is currently no pre-loaded iPad configuration for HandBrake like there is for the iPhone and iPod Touch so I created a few profiles that can easily be imported into HandBrake to output different sizes for the iPad:

Note that when you import videos using iTunes the iPad puts them in their own Videos app unlike the iPhone where they show up under the iPod app. You will want to find the Videos icon if you don't already know where it is:

iPad Videos Screenshot

After verifying that the above 4×3 version worked for the iTunes University video I went about testing it on a couple other video formats. I tested the Big Buck Bunny video that I also used for my post on iPad video streaming in both 640×360 and 1024×576 output formats. Both resolutions looked great. I also tried converting a DVD. If you decide to convert a DVD you will probably want to turn on de-interlacing in HandBrake. You do that by first selecting the "Picture Settings" option:

HandBrake Picture Settings Screenshot

Then the filters tab and then select the type of de-interlace you want (fast, slow, slowest):

HandBrake DeInterlace Settings Screenshot

If you want to use FFMpeg to do all this you can. The following is a slightly modified version of the streaming command I'm using that will output a high bitrate version of the input video:

ffmpeg -y -i input.avi -acodec aac -ar 48000 -ab 128k -ac 2 -s 1024×768 -vcodec libx264 -b 1200k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 1200k -bufsize 1200k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 16:9 -r 30 -g 90 -async 2 output.mp4
Posted in meta | Tagged , , , | 23 Comments

iPad Streaming Video and More

I've updated the configuration examples in the open source segmenter project to reflect Apple's recommended stream bitrates for iPad video streaming, added a few fixes and a few new features. If you are interested in streaming video on the iPad, iPhone or iPod Touch and haven't done so yet you it may help to start with my post on windowed streaming on for the iPhone, then read about iPhone HTTP streaming with FFMpeg and the open source segmenter and finally check out the iPad, iPhone, and iPod Touch live video streaming project page.

Here is a demo of the iPad streaming video created with the segmenter (I tried to show the progressive upgrade happening but it happens very quickly since the iPad is on WIFI, I also show that you can scrub without any issues and if you look in the background you can see the server log displaying entries as the segments are downloaded):

If you want to view the demo yourself I've created a demo for the iPad, iPhone, and iPod Touch. Note that those are two links, one for the iPad version and one for the iPhone/iPod Touch version. The main difference is the size of the video.

I used the open source video Big Buck Bunny (the 1920×1080 ogg version) for the above demos.

If you are interested in more details on what changed read on or skip to the bottom if you want to see what I'll be working towards in future versions of the segmenter.

Read More »

Posted in programming | Tagged , , , | 20 Comments

Using Cursors with PHP MySQLi and Multiple Prepared Statements

After my post on using PHP MySQLi and multiple prepared statements at the same time someone commented that using cursors could do the same thing. With that comment I dug some more and found that modifying the cursor type that is used under the covers will indeed let you execute multiple prepared statements concurrently on the same connection.

First off you may ask yourself why you would want to use this. The best answer I have for that is that the solution in the other post loads the entire result set into memory from the very start while with this solution you can control just how many rows you load. To get started you will want to take a look at the MySQLi statement set attribute call. This call is will let you modify the underlying cursor type that is used with the prepared statement in two ways that are useful for this issue.

Read More »

Posted in programming | Tagged , , , | Leave a comment

Spring 3 File Upload Example

I had the opportunity to figure out how to do file uploads using Spring 3 the other day and I couldn't find anything that pulled it all together. What follows is a complete example of how to do MVC based file uploads with Spring 3.

Read More »

Posted in programming | Tagged , , | 13 Comments

Parsing the SXSW Twitter Stream for Fun

Over the weekend I decided to toss together a simple twitter stream monitoring app that would capture SXSW tweets. I wanted to build on some of what I learned while hacking together the stuff for code2009 and it was also an excuse to play with node.js and a few other things. I figured I would put together a quick post with all the different parts and as I have time I'll pull together some of the more important sections into larger posts. Be warned that the site may stop functioning since it was only a few hours work and mostly put together with bailing wire and gum.

Server side:

  • node.js – Used to process the long polling requests
  • ngnix – Front for multiple nodejs instances and serving some static files
  • underscore.js
  • rabbitmq – Used to monitor the realtime feed
  • Redis – Used as a datastore for everything
  • ruby – Used to glue a bunch of things together, tons of gems used
  • Resque – Used to handle the screen captures

Browser side:

Hosting:

Posted in Uncategorized | Leave a comment

Using Daemon-Kit and RobustThread to Build Ruby Daemons

On a number of occasions I have found myself needing to assemble a daemon process for some type or processing done using Ruby. Each time I roll things a little different and I finally started to wonder if someone had already put together tools for doing the daemon parts. After some quick digging I ran into Daemon-Kit and after adding it together with a couple other tools it seems like what I've needed. I've put together a few recipes here to help guide others who might be looking for something similar.

Read More »

Posted in programming | Tagged , , , , | 1 Comment