Category Archives: projects

My personal projects

mp3 id3 tag whatsit

I bought a few mp3s from mp3sparks (formerly allofmp3) and was annoyed that the mp3s were not tagged with their track numbers but they were in the filename.

I had a quick look to see if I could fix this somehow. I found id3-py which I used to write a python script that fixes this and the artist,title and comment. One thing I noted was that you can only have a max of thirty characters in your track title. With a “Various Artists” album you want the artist in the title (Album artist is not in the id3 spec but it is supported by itunes and WMP). The concatenation of title and artist is quite often more than 30 characters – not good. Anyone found a way to write “Album Artist” to an mp3 using python?
mp3sparks is great but why in all things upside-down-monkey-drunk do I have to download each file individually and why do I have to right click (it is possible force a download guys).

I’ll upload an exe for installation that fixes your mp3sparks mp3s later.

Old School House Art Group is now live

http://www.oldschoolhouseart.com/
The last three nights I have been frantically building and populating my Mum’s Art Group’s website. I promised it to her months ago and it was due yesterday as a new exhibition started. I built it completely on WordPress (nine instances of it) and integrated with flickr (they can manage all their paintings and photos on flickr). The logo is shit and will change but for release it will do.

The design took me all of 30 minutes grabbing the colors from the logo. Have a wander, some of their paintings are quite good.

Halfviking get’s videos (ffmpeg, convert, flvmdi, flvplayer)

I’ve always wanted my online gallery export script to handle videos and last weekend, I bit the bullet and wrote it. I used quite a few Open source projects to accomplish this which means that PEAExport has a few dependencies but I think it’s worth it. My Canon Ixus takes AVI movies. The sizes of the movies range from 1MB to 50MB. To upload these would just be silly and each viewer would have to have an AVI viewer, which probably wouldn’t load in the browser. I really like flash movies players like those found on YouTube and Google Video so I anted to find a free one to use, I found the wonderful flvplayer @ http://www.jeroenwijering.com/. It’s an excellent player and free for non-commercial use.

So at this stage, I have my Videos in AVI format and a flash video (flv) player. I need to transcode them from AVI to FLV to work with the player. In work a few weeks ago we came across the SUPER application. This is a GUI front end to FFMPEG which is an absolutely wonderful utility, It handles tens of formats and hundreds of options. I used the FFMPEG.exe bundled with SUPER to tanscode them from AVI to FLV

ffmpeg.exe -i 'video.avi' -y -ab 64 -ar 22050 -b 200 -r 25 -s 650*450 'video.flv'

The options above (full list of options):

  • -i ‘video.avi’= input file is video.avi
  • -y = overwrite existing file if it exists
  • -ab 64 = audio bitrate is 64 kbit/s
  • -ar 22050 = audio sampling rate is 22050 Hz
  • -b 200 = video bitrate is 200 kbit/s
  • -r 25 = frame rate is 25Hz
  • -s 650*450 = rame size is 650 pixels by 450 pixels (WxH)
  • ‘video.flv’ = output file

Running this converts the hefty AVI video to a lightweight (relatively) FLV video. I then need to get the flvplayer playing this newly generated FLV.

<object data=”flvplayer.swf” type=”application/x-shockwave-flash”>
<param value=”file=video.flv&image=medium.jpg&linkfromdisplay=true&link=../14″ name=”flashvars” />
<param name=”movie” value=”flvplayer.swf?file=video.flv&image=medium.jpg&linkfromdisplay=true&link=../14″ />
</object>

There are many options for the flvplayer (full list of options). I only needed a few –

  • file=video.flv = input file is video.flv
  • image=medium.jpg = the loading image before you press play is medium.jpg
  • linkfromdisplay=true = when the user clicks directly on the movie area then they will be redirected to another page
  • link=../14 = when they click on the video, they will be redirected to the relative link “../14”

This plays fine but the progressbar isn’t running, This is a known limitation of FFMPEG (it’s fixed in the SVN version), FFMPEG does not write the metadata like video length etc to the FLV file. To do this, I was able to use another free utility called FLVMDI

flvdmi.exe video.flv video.flv

Running this inserts all the required metadata into the FLV video. The progress Bar now works perfectly.

You’ll notice that in the options for the flvplayer, I included “image=medium.jpg”. I could have used any image here but I wanted to use a frame from the video. Fortunately FFMPEG can do this.

ffmpeg.exe -i 'video.avi' -y -vcodec png -vframes 1 -an -f rawvideo -s 650x450 'videoimage.png'

The options above (full list of options):

  • -i ‘video.avi’= input file is video.avi
  • -y = overwrite existing file if it exists
  • -vcodec png = force video codec to png
  • -vframes 1 = set the number of video frames to one
  • -an = disable audio
  • -f rawvideo = force format to rawvideo
  • -s 650*450 = frame size is 650 pixels by 450 pixels (WxH)
  • ‘videoimage.png’ = output file

This results in a PNG file, quite a big one, taken from the first frame of the video. The file was too big for web use so I needed to convert it to JPEG. I could have used the Python image library PIL to do this (PEAExport already uses PIL) but I was already using some command utilities utilites to create videos and images. I thought, there’s no harm in another. That other was Convert.exe from the ImageMagick Library.

convert.exe -quality 75 videoimage.png videoimage.jpg

The options above (full list of options):

  • -quality 75 = compression level set to 75%
  • videoimage.png = videoimage.png is the input file
  • videoimage.jpg = videoimage.jpg is the output file

Excellent, I now have a lightweight flv video but I want a thumbnail to display in my gallery index pages. I ran the FFMPEG fram grap command but with “-s 250×186” to reduce the size to thumbnail size. I also want to indicate that it’s a video that the users is going to see and not another photo. So I need to Annotate it with the word “Video”

convert.exe -quality 75 -gravity South -font C:WINDOWSFontsGOTHICB.TTF -pointsize 50 -fill black -annotate +1+1 Video -fill white -annotate +0+0 Video videoimage.png videoimage.jpg

The options above (full list of options):

  • -quality 75 = compression level set to 75%
  • -gravity South = direction primitive gravitates to when annotating the image – In this case, we want the annotation loacted in the South of the image
  • -font C:\\WINDOWS\\Fonts\\GOTHICB.TTF = The font for the annotation. In this case I am using Century Gothic Bold
  • -pointsize 50 = The font size is set to 50 points
  • -fill black = The fill of the annotation is to be black
  • -annotate +1+1 Video = Annotate the word “Video” plus one pixel in both directions from the base position of “South”
  • -fill white = The fill of the next annotation is to be white
  • -annotate +0+0 Video = Annotate the word “Video” plus zero pixels in both directions from the base position of “South”
  • videoimage.png = videoimage.png is the input file
  • videoimage.jpg = videoimage.jpg is the output file

This creates a thumbnail image with the word “Video” in white with a black drop shadow, in Century Gothic Bold font, size 50 points.

thumbnail image with the word Video

And that my friends is it. Enjoy all my vidoes @ http://www.halfviking.com. I have also created a new page @ http://www.halfviking.com/videos using flvplayer’s playlist feature. My favourite single video is Bobby very bemused as to what on earth is planted in the ground at Crosby beach north of Liverpool.

Geek resolutions

As it’s new year and my motivation is at an all time low, I think a list of TODOs (or new years resultions) is needed. Some of those listed are techy and some are not but all of them are aimed at improving my life.

I will

  • Finish the new design of this site – as you can see, it’s still a work in progress
  • Comment my code
  • Finish projects I have started
  • Document my code properly
  • Use UML – even if it’s just in my head
  • Move to Ubuntu on my home machine
  • Caption all my photos – all 8500 of them
  • Read all the books I bought
  • Read non-techy books too
  • Cook more
  • Eat less
  • Eat healthier
  • Find some way of feeling healthier that I can actually stick to (Gym is a bit too much commitment)
  • Start to budget my outgoings properly
  • Stop calling my dog “the rodent”
  • Learn that Friday does not have to equal “getpissedday”
  • Stop watching soap operas – comedy series like King of Queens and Scrubs will remain on my Sky+ planner though
  • Contribute to an open source project
  • Help fellow developers more
  • Always keep in mind that I know only a fraction of what I think I know
  • Be in a good mood
  • Write another useful Firefox extension that uses a custom XPCOM component
  • Use Patterns in code more
  • Stop driving like an idiot just so I can get home quicker
  • Go to Ireland to see my friends and family more
  • Go to the summer house in Norway
  • Save money
  • And finally – keep this blog up to date

There’s quite a few there so I think it’s more of a two year plan. I have been working on an eight year plan with Gill too, but it’s still a bit up in the air but very exciting – as along as all goes well –

I will also (I thought of some more)

  • Move to IMAP instead of POP email
  • Backup more
  • Learn how to use SVN properly
  • Go to LinuxWorld in London (as long as it’s not on Gill’s birthday like last year)
  • Get a whiteboard at home
  • ……..I’ll add some more as I think of them

Aggreg8 lives

This weekend I have gone on an all out Open Source offensive. I have released a new version of ACR (Automatically Create Rewriterules) with some bug fixes and faster processing of sites. I have released an updated version of PEA (Photoshop Elements Album Export) with improved accessibility and more options in the python script header.

Aggreg8 lives again I also started work on Aggreg8 again. I have a working version for Firefox 2.0 (not released yet) which will be my basis for my future plans.

  • Get Aggreg8 working on Firefox 2.0 – Done but not released
  • Get auto-subscribe working – Done but not released
  • Use built in Feed parser
  • Use SQLite for storage
  • Have an options panel
  • Ability to import and export OPML
  • Clean up XULs and Javascripts – especially the location of some functions
  • Add license to header of each file (MPL)
  • Create some nicer CSS stylesheets
  • Create a Norwegian language file
  • Change all references of Aggreg8.net (now a microsoft portal) to Aggreg8.org
  • Implement some sort of caching (although the aim of Aggreg8 is to be simple – caching might be overkill)

After 3 years of inactivity on the aggreg8.mozdev.org site. I am again on the active projects list and am raring to go with the above features. The aim of Aggreg8 version 0.3 is to be a super simple RSS reader with no fancy feature, just an easy way to read your RSS feeds. Using SQLite and the built in parser, I hope will improve performance too.

auto rewrite rules and google sitemap generation

Although we’re very busy in work at the moment, the last few evenings I have been pythoning myself up and have come up with 3 nifty little scripts.

Usage of all three is quite simple –

python scriptName.py http://www.karova.com

There is also a zip archive for download. As you can see I have started using Google Code project hosting. It suits my needs perfectly as it’s simple to use and the SVN server they are using is hellish quick. I’ve named the project acr (Auto Create RewriteRules). For a sample of output see http://www.karova.com/sitemap.xml . The rewrite rules was written as a personal project but also for KarovaStore – So expect release 2.1 to have clean urls and auto google sitemaps.

Update:

Yes I know Google have their own sitemap generator but mine is alot easier to use.

Aggreg8.net sold

None of you will have noticed that Aggreg8.net and Aggreg8.com are now actually hosting Microcosm which is a Microsoft portal of some sorts.

I was approached about a month ago to see if I would sell Aggreg8.com. Hell yes. I suggested $3000 as I could not be bothered getting into a to and fro debate on the price. I also offered Aggreg8.net for $2000. Both suggested prices were accepted and the domain transfer proceeded using Network Solutions certified offer service. I am yet to receive the checks but I am well chuffed and after £2000 in the last 2 months on car repairs – it is definitely needed.

I have since purchased Aggreg8.co.uk and Aggreg8.org so my Aggreg8 RSS reader will be moving there once I get a chance.

Half Viking Gallery Goes Live

HalfViking.com
It’s been a while on the back burner but this weekend I went hell for leather and managed to get the necessary coding done to get Halfviking.com live.

I manage all my photos 6000+ photos in Photoshop Elements and I am very happy with how it copes but it’s web gallery export sucks ass.

What I found was that PSE stores it’s data in an Access database. I wrote (using parts and few sub routines form album2gallery) a perl script to extract the data in the DB and write it to XML.

I then wrote a wad of python to parse the XML and create a static version of the gallery you now see. Using the Python Imaging Library I also managed to resize all the images to thumbnails and larger versions. All my photos are up now…. I have nothing to hide 🙂 .

There is still a couple of hitches (some duplicate albums [now fixed :)] and it’s not browser tested and I want to add some funky javascript) but I couldn’t be arsed waiting any longer… enjoy (or not)