Monthly Archives: March 2011

AmazonSES API wrapper for Railo/ACF


As I alluded to this morning, I have been working on a wrapper API for the Amazon SES service.  It is not yet completed, but it is functional enough to get you sending some emails through the gateway. Currently it will allow you to get a listing of emails addresses verified with Amazon Web Services, create a verification email so that you can verify your email address with AWS as well as actually sending an email through Amazon SES.

Integration with Railo (and presumably ACF) is straight forward.  First, download the Java SDK for AWS.  Extract the file and in the ./lib folder you will find the jar file we will need to move into your classpath for Railo/ACF.  At the time of this writing the file is aws-java-sdk-1.1.8.jar. I generally use the Viviotech installer which places Railo in /opt/railo on Linux and I copied the SDK jar to /opt/railo/lib. Restart Railo so all the jars will be reloaded giving us access to the API.  I do not have access to an ACF server so your mileage here may vary.

The server configuration done, now you just need to go to AWS and get your access key and secret key.  These are required to authenticate your connection to Amazon and should be stored in the AwsCredentials.properties file.  You obviously want to keep this file protected so I would suggest storing outside of your web root or create some rules on your web server to ensure no one can view the file.  Once you have this setup it is time to send some emails!

Sending an email is extremely easy to do.  First create a new instance of the amazonSES component and then invoke the sendMail method passing in the required parameters (from, to, subject and the message body).  If you have not already verified your address with Amazon, the script will create a new verification email and send it to your email address and then throw an error letting you know you need to check your email for the verification.  If you have already verified your email address it will just send the email out.

That is about all I have for tonight.  As noted above, I have only tested this on Railo, I do not have an ACF box to verify against.  It will probably need to be modified to handle multiple message recipients (I have not tested this yet). I plan on working on some new features this weekend if I have a little free time.

I have included a simple application you can use to test the installation.  If you have any questions, problems or suggestions, please let me know.

Update: I have created a RIAForge project for the AmazonSES API wrapper.

Update 2: I have linked to the older version of the AWS API on my forum and you can download the file here if you are having issues.

AmazonSES: Sending your verification email with Railo


I have a client that I am in the process hooking into Amazon’s Simple Email Service for handling their member and mass e-mails.  Originally I was trying to do this through their Google Apps e-mail but it has been problematic at best because Google keeps disabling their mailing account.  Needless to say, it is not fitting their requirements.

My buddy Todd suggested moving them to AmazonSES and after looking their product it looks to be a good fit for my client.  I have not found a wrapper for their API for ACF/Railo so I am working on getting a wrapper together that I will release as well as document the steps you need to take to get this working on your own installation.

The first step in getting AmazonSES working is sending the verification email to your account.  Amazon’s web site has a script written in perl you can use to send it, but I did not feel like installing extra software on my server just to get the account setup.  Instead I decided to do it through the Java API on Railo.   I did not find any examples of how to do it, so I just had to figure it out myself.  Hopefully it will help someone else out.

<cfscript> 
 awsCredentials = createObject("java", "java.io.File").init("#expandpath('.')#/AwsCredentials.properties");
 credentials = createObject("java", "com.amazonaws.auth.PropertiesCredentials").init(awsCredentials);
 email = createObject("java", "com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient").init(credentials);
 verifyRequest = createObject("java", "com.amazonaws.services.simpleemail.model.VerifyEmailAddressRequest").withEmailAddress("your@email.com");
 email.verifyEmailAddress(verifyRequest);
</cfscript>

In the verifyRequest assignment the your@email.com with your personal email address and a verification will be sent to your email.  After activation you can start sending out emails from your verified address. I will put a more detailed installation guide later this evening.

Update: You can also read about the completed AmazonSES component.

Serviio DLNA media server


The last few weeks I have been working on ironing out a few issues I have been having streaming media to my consoles.  MythTV does offer a UPnP media server, but for one reason or another my luck with it has been hit and miss at best.  The hardware on my MythTV machine is  a little dated and I have no plans of updating it any time soon.  With that in mind, I thought it might be a good idea to offload the streaming to my work machine because it has enough processor and memory to handle it.

With that in mind I set out to find a good media server and came across Serviio DLNA media server.  One of the key features to me was the fact that it was written in Java so it will work on multiple platforms including Linux, Mac and Windows as well.  Any device that supports DLNA 1.5 should work just fine as well as the Playstation 3 and Xbox360 (I only have the XBox360 and that works a treat).

Installation on Linux is straight forward; I downloaded the application and extracted it into my home folder.  I believe the Windows and Mac version has a pre-compiled version of ffmpeg and LameMP3 encoder  included with it (the server also supports transcoding on the fly although I have not tested it).  Linux users will need to install ffmepg through their distributions package manager or by compiling it manually.  I already have the lastest ffmpeg compiled on my machine so I was ready to go.

The next step was to start up the service and get it configured.  On linux this is accomplished by running the serviio.sh script file.  Once that is up and running you just need to run the console (serviio-console.sh on linux) and get things set up the way you like.

After getting the service configured everything just works.  Serviio has some nice metadata options and can identify ID3 tags, WMA tags and EXIF tags in images.  Also when you connect to the server it gives you a nice breakdown of your media including recently added, recently watched, a breakdown by actor, etc.

I have not had a lot of time to play with it really in depth, but if you are looking for a home media server it is definitely worth checking out.  I plan on playing around with it a little more in depth this weekend when I have a little free time.  If you have some experience with it please let me know what you think.

FireSSH plugin for Firefox


While scanning through my news feeds this morning I found a cool plugin for Firefox called FireSSH that, as the name alludes too, allows you to SSH to a host from your web browser.  Once the plugin is installed you can paste an SSH address in the url bar and go.

Now I just need to find something like this for Chrome.

Using ColdFusion/ffmpeg to create a panning video


I came across an interesting post in the Railo groups about using Railo’s CFVideo plugin to create a panning effect using images.  I quickly threw together a little demo to show how this can be accomplished.  Since the CFVideo tag still has not been released to the core providers, I whipped up a little demo using just ffmpeg.  I know the quality is not all that great here, but this was a proof-of-concept.

First, I went and found a 1024×768 background image.  Since I was reading Ben Nadel’s post about the Conflict of Truth, I was inspired and grabbed a Matrix image (that movie still rocks).  Next step is to crop the images we will eventually use to stitch together our animation.  I realize I am setting my bounds a little small here but, as I said, this was just a PoC.  I decided to let Railo do the heavy lifting for me.

<cfset imgOriginal = ExpandPath(".") & "/3posters-trilogia-matrix.jpg" />
<cfImage name="readImage" action="read" source="#imgOriginal#" />
<cfloop from="1" to="827" index="x"> 
 <cfset workImage = imageRead("#readImage#")/> 
 <cfset imageCrop("workImage", x, 1, 200, 200)/> 
 <cfimage action="write" source="#workImage#" destination="#expandPath(".")#/stock/img#NumberFormat(x-1, "0000")#.jpg" overwrite="true">
</cfloop>

There is not a lot going on here.  I preload my original image and then pan from left to right across the image one pixel at a time.  Each time I shift a pixel I save an image into the ./stock/ folder.  I will forewarn you this is very processor intensive so upping the default page timeout is required because 50 seconds will not cut it (on my workstation at any rate).  Now we should have 827 nice images  in our stock folder.  Now it is time to run ffmpeg on this to package it up into a video.

/ffmpeg/bin/ffmpeg -r 10 -b 1800 -i img%04d.jpg test1800.mp4

FFMpeg runs considerably faster stitching together the image into the video and will quickly spit out our end result:

Off-topic but awesome


I am a casual gamer for those of you out there who may not know me.  The other day I retweeted a list of games for Linux, my OS of choice, and in that list there were links to open-source Quake 3 Arena clones.  I have played Quake for years and I played Doom before that.  Between work and the family I do not have a lot of time to play games but sometimes, in between coding, it is therapeutic to go and blow some stuff up.  The only problem with the open-sourced implementations of this is if you do not own the original game you will not have the WADs for the maps.  While there are ways around this, I have gotten legit in my old age so this didn’t really appeal to me.

Then out of the blue, I remembered my friend Sean told me to check out Quake Live a while back.  Some of you may be familiar with this but for those who are not, Quake Live is an implementation of Quake 3: Arena in a web browser.  There is a plugin to install, but the game is free to play and is supported by ads.  They offer a subscription where you can play ad free, but I don’t mind  waiting to play.

As a web developer I tend to feel pretty spiffy when I do something cool with just a web browser, but Quake Live just nails it.  Running in full-screen mode it is easy to forget the game is running in a web browser.   It has all the options you would expect: key bindings, player models, network play.  The first time you play it you will have to install the plugin and then wait a few minutes while it downloads the game data (presumably the map packs, etc).  The one thing I did notice, and this might be a Linux thing, all the opponent character models appear to be the same for me when I am playing.  However, when you are spamming rockets they all look the same.

This is definitely a blast from the past (no pun intended) and my new form of anger management.  I still like to hop on WoW every now and then, but when you just need a few minutes of  “relaxation” this is great.

Check it out: http://www.quakelive.com

MythTV installed


This weekend I spent quite a bit of time replacing my ailing Windows Media Center PC with MythTV (using the Mythbuntu installation).  I am sure it would have been easy enough to start with a clean distribution and install all the needed parts, however, Mythbuntu already has everything rolled in so it was a no-brainer.  Overall I would have to say it was a pleasant experience.  I did lose about a terrabyte of previously recorded TV since it was stored in Microsofts video format, but sometimes you just have to deal with the collateral damage.

Installation of MythTV is fairly straight forward, but it was a huge change from setting up WMC where it would just automatically detect the tuners and just work.  Setting up capture cards in MythTV is not much harder than it is in Windows.  The one extra step you have to take is setting the default input for the capture card which in my case was setting the tuner to the default input.  Another big difference was setting the channel guide listings.  In WMC you just enter your zip code, select your cable provider and it just worked, with MythTV that is not exactly the case, in the States at any rate.  The listing provider here will give you a 7 day free trial and after that it is $5 a month or $20 a year.  When you compare that cost to the cost of a Windows license just to run your home theatre I know which I would rather pay.

After getting the base system configured is where the real fun begins.  I have a 1TB drive installed in the HTPC machine where I keep all of my recorded media that needed to be setup.  In Windows, this is a matter of setting the storage to the drive, in Linux the process is a little more convoluted.  First I reformatted my drive to an ext3 filesystem and then mounted that to my Linux file system at /var/lib/mythtv (the default location where MythTV stores all its data) and created an entry for it in fstab so it would automatically be mounted at boot. Then I recreated the directory structure on my mounted partition.  I also have a 500GB external drives I mounted and set in fstab to use for videos and created a symlink to it from the mythtv data directory. All things considered, these are just basic tasks you need to perform in linux on a day to day basis, but when you are used to working on the desktop these are things you may or may not be comfortable with so you might not be in your comfort zone.

Once everything was up and running it was just a matter of playing around with it.  I have used WMC for about 5 years or so, so I was interested to see how I would like it and I was not disappointed.  It did take a little getting used to (if you don’t have everything configured just right it has a habit of crashing MythTV front end and you need to restart it), but once you have everything working smoothly it really is a dream.  There are a lot of options for setting up your scheduled recordings that I have not really played with in depth, but it is definitely functional and WMC could really take some notes on how to accomplish this better.

However, where this really shines is in the video management.  My kids love to destroy DVDs.  No matter how many times I tell them how to handle them, always put them in their case, etc, etc, invariably then end up on the floor or playing frisby with them.  So to save my investment I started using Handbrake to make a backup of my purchased DVDs and then safely put the discs away so they would not get ruined.  When the kids wanted to watch a movie they could go to Movies in Media Center or connect to Media Center through the XBox 360 to watch their movies.  I was pleasantly surprised that with UPnP, the Xbox 360 will easily pick up MythTV and allow streaming the videos.

Mythweb manager

Mythweb makes managing your shows painless

Another huge feature that MythTV has over WMC is the Mythweb plugin.  One of the greatest features in my opinion are the TV functions, the ability  to view TV guide listings from any computer on your home network.  If you want to record a show just find it in the guide, click on the program then schedule your recording.  You can also manage  your recording schedules and view upcoming programs that are scheduled to record.  This is a feature Windows Media Center should have added ages ago.  I cannot tell you how many times we have run into the living room to check the channel guide or just to make sure a show was recording.  Now we can check from any room with a computer.

Not only can you manage your shows through the Mythweb interface, you can also watch your recorded shows through the web browser as well either as an ASX stream or you can do a direct download if you are not at the house to watch it.

The same applies to your stored videos as well, you can easily watch any of your movies stored on any web browser.  If your browser does not support that file type, you can easily copy the url into an application (such as VLC media player) that can play a video from a web stream.

Overall I would have to say I am happy with the transition from Windows Media Center to MythTV.  I will not say there were not obstacles that had to be overcome and there are still plenty of tweaks that I need to make to have everything running smoothly.  Since I am no longer running Media Center, the buttons on the remote do not always function as they did before, however, after using WMC for years I am sure that there will be a little bit of a learning curve.  On the bright side, you can easily edit the configuration of the remote control through an XML file so it is just a matter of spending time to really RTFM and get things working.

MythTV vs Windows MediaCenter


I have been using Windows Media Center as my HTPC of choice for years now.  Recently Media Center has started crashing several times a day so I thought it might be time to mix things up a bit.  I have looked at a few other solutions, some running Windows and others running on Linux.  I could easily reload my HTPC machine with Windows, but ideally I would like to move on to something open-sourced and preferably on Linux; all my other machines run on various Linux distros. The main reason why I have not switched before is because I have about 2 TB of recorded video in Microsoft format that I did not want to lose, but now that I am having problems with the machine the collateral damage is not really an issue.

Currently I am looking at installing Mythbuntu to handle the HTPC role.  Basically I am just looking to see if anyone has made this switch and has any helpful hints on making the transition.  The biggest thing for me is the Media Center remote which looks like it will work well with MythTV.  I plan on transitioning over the weekend and I would love to hear about your experiences.