bella, bella, bella

March 5, 2010 by snowb0y

When my phone rang for the fourth time I knew something was up. So once I’d escaped a work-discussion about publishing image pyramids I phoned home. Sure enough there was a crisis. Nelson had taken Bella outside and now she was lost.

Bella the dog

Bella the dog

After much panic Bella was discovered INSIDE-THE-NEXT-DOOR-NEIGHBOURS-HOUSE. It turned out later that Bella had sneaked inside while Clare (our neighbour) had been unpacking and chatting with another neighbour. After the discovery, Clare was contacted and kindly cut-short a shopping trip to return home and release the imprisoned pooch.

As Clare explained later, there were thirty-five chocolates in the bag. The girls had had two, that’s one each leaving thirty-three for Bella plus various sherbert dips and packets of refreshers. All the sweets were gone, wrappers and all. I think Bella is expecting us to take her shopping next week.

M6 mania

February 20, 2010 by snowb0y

Last Thursday we packed the kids and dog in The Mighty Berlingo (pronounced berrrLin-Goooo!) and headed for my parents place in Gatley, which is just south of Manchester. As with previous journeys I started to get stressed on the approach to Birmingham. It seems that none of the roadworks that wound me up six months earlier are any nearer completion. So on top of the driving rain, occassional snow-drifts and arguing kids we’re packed liked sardines into lanes that appear to be narrowing while the artics hang closer on to our bumpers. By the time I get to final dash (J15 – J20 M6 northbound is the 5th worst place to drive in the UK according to the RAC) I am barking. It really is complete insane. But like a party that went too far, we get up the next morning and wipe it from our collective consciousness. Until next time.

Potatoes

February 14, 2010 by snowb0y

I need to plant some. We are blessed with a couple of acres of unused land next to us and it needs to have potatoes growing in it. There are two obstacles. The brambles have stems like oak trees, and the land is owned by someone I’ve never met: but apparently he’s a real nasty. The brambles are lethal but armed with my mighty scythe and trusty rake I’m well on the way to clearing 48 square metres. Mr Nasty is something of an unknown but I feel quite determined that the growing of potatoes on someone else’s unused land is not a moral problem, even if it may become a legal one. Technically that makes me a guerrilla gardener which is quite exciting :-) . I do actually think it’s rubbish that we import potatoes from places like Egypt. The only downside is that I will need to purchase 133 early and 211 maincrop seeders. This is an outlay of eighty quid. which is possibly more than I’ve spent on potatoes in my entire life.

The Great Flakes

February 6, 2010 by snowb0y
daddy snapped by ruben

daddy snapped by ruben

After the long winter, like some ancestral awakening we were drawn to the outdoors. Lake Flake and it’s neighbour Lake Caramel was our destination. The watery sun, the mossy trees and the forgotten stream together with the happy sounds of carefree and muddy children. I was struck deep. And today a new discovery Lake Galaxy! The adventure continues.

How to make a media player

January 31, 2010 by snowb0y

I was looking for a little project to keep me busy over Christmas and decided to have a look at organising the contents of /home/media. The media directory on my Red Hat Linux box holds:


3523 audio files
595 video files

It got called jplayer because its for private use (by the johnsons) and j follows i and the flash player I used is called jwplayer.

Some top-level ideas

  • Things should be bookmark-able
  • Editing and managing meta-data had to be possible during playback.
  • And some of the RESTful ideas that are running around from my day job should find their way into the design.

In the end it was made using: Perl, MySQL, Apache (XSSI), Javascript including SWFobject, Flash (JWplayer) and CSS. My background is in Perl and database so the challenges were going to be in the javascript and CSS. Here is a step-through the process of creating and playing a media file.

On the command line use

find

to make an input file. Looks like this:

file=/audio/morcheeba/shoulder_holster.mp3
file=/audio/morcheeba/fear_and_love.mp3
file=/audio/morcheeba/dungeness.mp3

And then use curl to upload those entries to the database using an HTTP PUT

$ curl -T .avlib http://localhost/cgi-bin/avlib.pl
added 3 rows ok

To start playing the files I have to use a browser and enter a search phrase. An onClick() event creates an Ajax call to the web service. It looks like jplayer/?q=morcheeba

The output from the web service produces a list.


<ul>
<li>
<a href="/jplayer/?playlist=/audio/morcheeba">morcheeba</a>
<div class="summary"></div>
<div class="small">audio/mpeg</div>
</li>
</ul>

Results are piped through a pager so you scroll through 5 items at a time. Selecting an item from the search results loads a new page (to get the bookmark) and displays the playlist. In this context a playlist is just all the files in a folder. Each file has a link that will load the movie into the player and displayer the meta-data in a webform. For example:


<a href=""
onclick="loadSWF( '/audio/morcheeba','shoulder_holster.mp3' , 'jwplayer');
updateForm( '/audio/morcheeba','shoulder_holster.mp3');
return false;">shoulder_holster>/a>

Playback is controlled through the Flash object. Once the meta-data is updated an Ajax calls generates a POST to send the new data to the server.

The web service


PUT /path/to/avfile
200 returns text summary of new rows added
400 returned zero rows

POST a set of REQUEST VARIABLES representing an item
200 returns string saying 'thanks'

GET ?q=Search+String
200 returns a paginated list of playlists matching string

?playlist=/path/to/file
200 returns data items as a web form

no parameters displays name and version

The Perl uses the HTML::Template module to create the presentation layer and the DBI modules to access the MySQL. Otherwise it’s hand-written, even the CGI functions (I was surprised that CGI.pm didn’t help do the PUTs).

Data schema


CREATE TABLE playlist (
pk_pldir varchar(255) NOT NULL,
playlist varchar(127) NOT NULL,
mimetype char(23) NOT NULL,
summary varchar(1023),
PRIMARY KEY (pk_pldir)
);

CREATE TABLE avfile (
pk_pldiravfile varchar(255) NOT NULL,
fk_pldir varchar(255) NOT NULL,
avfile varchar(255) NOT NULL,
title varchar(255) NOT NULL,
duration int(4),
thumbnail varchar(127),
PRIMARY KEY (pk_pldiravfile)
);

CREATE TABLE pldir__tag (
pk_pldirtag varchar(255) NOT NULL,
fk_pldir varchar(255) NOT NULL,
tag varchar(63) NOT NULL,
PRIMARY KEY (pk_pldirtag)
);

Web client

There are 3 main areas of the page.

  1. banner and search box
  2. SWF player window and playlist panel
  3. search results OR html form to update playlist metadata

I don’t have a server to host jplayer on tinternet, but here’s a screen grab:

screenshot

To do

  • Currently I’m using AVS to convert movies FLV. Have upgraded ffmpeg 0.5 and would prefer to use ffmpeg for scripting
    • a series of thumbnails (or if audio use album art or an icon)
    • calculate the duration
  • Improve search by filtering through audio or video

References

JW Player
HTML playlist
FFmpeg
Ajax
SWF Object

Elasticated waistband

January 31, 2010 by snowb0y

I heard someone say on the radio that they were getting to the point in life where happiness is wearing something with an elasticated waistband and taking a nap. Sad but true.

Gypsies entertain the brethren

January 31, 2010 by snowb0y

I’ve never been inside a masonic lodge before. That’s one of the best (and worst) things about being a live performer — you travel a lot. Despite a somewhat faded grandeur The Guild Hall has an impressive architecture that was teeming with life at the brethren’s annual let-the-wives-in event. We Gypsies (also known as 5 Go Swing) swung hard and were rewarded with some yi-haw clapping and blushingly nice compliments from our host. As I scanned the audience I looked for familiar faces (Dan Brown?) but it wasn’t my kind of crowd.

Amusing Our Leader

January 31, 2010 by snowb0y

My friend and I were discussing cats, dogs and how they adapt themselves to human families as if we humans were animal packs. While much has been said about dogs and the alpha male, my friend was telling me about a new theory concerning cats. Apparently our behavior towards cats engenders them to consider themselves as pack leader. With this freshly in mind I came across Ruben (my youngest) grimacing at our largest cat Kovu. Ruben wasn’t just grimacing, he had his little fingers rammed into both corners of his mouth which was pulled taut with a waggling tongue in the middle. His eyes were rolling around like dishes and his head was waving from side-to-side. I asked him why he was pulling faces at the cats. Ruben jumped up and down, and round and around for a bit and then squeaked “to make them laugh of course” and resumed his facial postures. I looked at Our Leader. He was not amused.

Web logs and fallen trees

January 24, 2010 by snowb0y

A tree near my house has fallen and blocked one of our favorite footpaths. Time to get the chainsaw out :-) . Things were going well until the saw suddenly stopped dead with the chain pinched tight by the stricken branch. Hmm. After getting angry and swearing had failed I realised that the saw was going to have to be freed by a smaller, hand saw. I felt the humiliation of the bigger saw. Like a mighty and powerful minister trapped in a doorway, he could do nothing but roar and wait while civil servants lowered floorboards and trimmed joists. Everyone needs friends, even the big and powerful.

Travelling bees

January 18, 2010 by snowb0y

Driving a car with young children inside is like being in a jam jar with a swarm of buzzing bees. It’s great when you take the lid off. Wooosh.