Moved transcoding process to Amazon EC2

It was quite easy to move the transcoding process for the railscasts podcast to an EC2 instance. I installed an ubuntu instance similar to the vm I used before, and added a cronjob on my home pc to automatically start, stop the instance and run the transcoding process via ssh.

Most of the work is done through the Amazon APIs.

#!/usr/bin/env ruby
# simply run job on ec2 instance
#
# Author: gschaden at gmail dot com
# Date: August 2010
# Version: 1.0
#
# connect to amazon ec2 and start an existing instance
# after the instance has booted, run commands via ssh (public key, authentication)
# then stop the instance
# if the job takes to long, it is aborted
#
# This script requires following gems
#   amazon-ec2
#   net-ssh
#   system_timer
#


require 'rubygems'

require 'AWS'
require 'net/ssh'
require 'system_timer'

AWS_ACCESS_KEY_ID = 'PUT KEY HERE'
AWS_SECRET_ACCESS_KEY = 'PUT SECRET KEY HERE'

# path to pem file, e.g /home/gschaden/.ssh/ec2.pem
SSH_KEY = 'PATH TO SSH KEY' 

# command to execute 
REMOTE_CMD = 'transcode.sh'

# instance id, eg. i-3dfb8edf
INSTANCE_ID="PUT INSTANCE ID HERE" 
JOB_TIMEOUT=10*60 #seconds

exit_code = 0

begin
   conn = AWS::EC2::Base.new(:access_key_id => AWS_ACCESS_KEY_ID, :secret_access_key => AWS_SECRET_ACCESS_KEY)

   # start your instance
   puts "----- start instance -----"
   conn.start_instances(:instance_id => [INSTANCE_ID])


   # wait for your instance to start up
   puts "----- listing instances -----"
   while true do
      instances=conn.describe_instances(:instance_id => [INSTANCE_ID])
      state = instances.reservationSet.item[0].instancesSet.item[0].instanceState.name
      break if state == "running"
      puts "waiting"
      sleep 1
   end

   ip_address=instances.reservationSet.item[0].instancesSet.item[0].ipAddress
  sleep 10
   puts "----- running ssh #{ip_address} ------"
   SystemTimer.timeout(JOB_TIMEOUT) do
      begin
         Net::SSH.start( ip_address, 'ubuntu', :keys => [SSH_KEY] ) do |session|
            puts session.exec!(REMOTE_CMD)
         end
      rescue Timeout::Error
         puts "Job timeout"
         exit_code = 1
      rescue SocketError
         puts "Could not connect to your instance"
         exit_code = 1
      end
   end

   puts "----- stop instance -----"
   puts conn.stop_instances(:instance_id => [INSTANCE_ID])

   puts "----- listing instances -----"
   while true do
      instances=conn.describe_instances(:instance_id => [INSTANCE_ID])
      state = instances.reservationSet.item[0].instancesSet.item[0].instanceState.name
      break if state == "stopped"
      puts "waiting"
      sleep 1
   end
rescue AWS::InvalidInstanceIDMalformed
   puts "Invalid instance id"
   exit_code = 1
rescue AWS::AuthFailure
   puts "Invalid credential, check access access_key_id and secret_access_key"
   exit_code = 1
rescue SocketError
   puts "Could not connect to EC2: ",$!
   exit_code = 1
end
exit exit_code

Railscasts for Android

I realy like the railscasts screencast by Ryan Bates, but the video does not work on my new htc magic. So I encoded these with another codec suitable for viewing on an android phone. This feed will automatically updated if there are new episodes.

The new link to the rss feed:

http://feeds.feedburner.com/gschaden/railscasts

http://www.gschaden.com/railscasts/android




Original railscasts site

Please report any problems about the video here.

The script to convert the screencast can be downloaded here.

The most interesting part is the call to mencoder to encode the video

mencoder src.mov -o dest.mp4 -of lavf -lavfopts format=mp4 -ss 1 -sws 2 -vf scale=480:320 -ovc x264 -x264encopts crf=30.0:nocabac:level_idc=30:global_header:threads=2 -ofps 30000/1001 -oac faac -faacopts mpeg=4:object=2:br=128:raw -channels 2 -srate 44100 -af volnorm

FHEM iPhone Gateway

fhemgw ist ein Skript, welches ein Gateway zwischen dem fhem.pl Skript und dem iPhone schafft.

Das Gatway ist in PHP entwickelt und bietet derzeit folgende Funktionen.

  • Anzeige der FS20 Komponenten und schalten der Funktionen
  • Anzeige der KS300 Komponenten
    • Anzeige eines Graphen für die Temperaturentwicklung

Sceenshots:




Download:

Version 1.0

mp3 to Audiobook

Heute habe ich mir endlich ein Skript geschrieben, dass es mir ermöglicht Audiobooks aus mp3 Dateien so zu generieren, sodass mein iTunes für jedes Buch separat die Position speichert und auch synchronisiert. Bisher habe ich die einzelnen mp3 Dateien zu einer Playliste zusammengefasst und so abgespielt, leider vergisst der iPod nach jeder Synchronisierung meine letze Position in der Playliste.

Download: http://www.gschaden.com/ab/mp3toaudiobook.zip

Mika als Kamerafrau

Beim Surfen bin ich über Mr Lee Cat Cam gestolpert; das musste ich natürlich gleich ausprobieren. Nachdem ich letzte Woche die Kamera erhalten habe, war es nun am WE an der Zeit die ersten Fotos zu machen, oder besser machen zu lassen.

Kimi weigert sich die Kamera zu tragen, aber Mika findet nichst besonderes dabei. Weiter Bilder gibts unter picasaweb.