The life and times of the younger, lesser spotted chicken.

Friday, July 29, 2005

The airport official can only show you the door. You must walk thr ough it.

Point is, is that you'll only know how many people are inside the toilets if you check it out for yourself.

Friday, July 22, 2005

Go Count Them

By law, all 1-ply toilet rolls must have 500 sheets. Count them.

Jozi and the Giant

I feel the beat of Jozi's heart, throbbing deeply beneath my feet.

I'm in Joburg visiting Jen's family and the trip has been nothing short of intense. We meet with family and friends countless times a day and rush around the spaghetti freeway of Jozi like a tunneling ferret. I'm tired. I've forgotten what it's like to sleep in till lunch and pass the day with geeking. I am keen to return to the chilled out vibes that course through the veins of the Puddle and greater Grahamstown.

The visit to Jozi has been amazing though, meeting Jen's family (although nerve racking at times) has been really awesome and I'm glad to now know my extended family :-)

We toured Constitution Hill yesterday, which was incredible. I had no idea what to expect and after wandering through that life changing piece of history, I now have so much more respect for our country and realisation of the challenges we face in advancing from our troubled past. I plan on blogging a whole lot more about it, upon returning to Rhodes. Right now, I wait for Jen's highlights to take effect and her hair dressing appointment to approach completion. Have you ever noticed how much hair she actually has!? ;-)

Thursday, July 07, 2005

this music will change your life

I found some amazing Trance type music. It's this random swedish dudes mixes of about an hour in length. They're really kief. Starts off really chilled and then works up, quite awesome to geek to :-) It's at Da-La.com, under the mixes section. Personally, I prefer the first "Digital Alchemy" mix, especially around 18 minutes in. Wow.

Tomorrow the journey back home to Durban starts. It's a grueling ten hour trip through the Transkei and other spectacular places. Me and Jen are gonna start the journey at 3am tomorrow morning. She's working all day, and then going to a "rap" party (See, thats what they call an end of project party in the "industry") so won't be much company in the car tomorrow :-P Nonetheless, I will be getting to sleep pretty early and then waking up to drive most (if not all) of the way.

The whole "driving all the way" thing is not because of Jen's driving, or her keen-ness for driving, but rather my enjoyment of, driving. I really enjoy doing the whole journey from here, taking Sopwith to new boundaries :-) Sopwith is, nevertheless, just a camel (Sopwith is my jade 1994 Toyota Conquest). Yah, so I really enjoy driving the distance, and if I do happen to get tired, I will let Jen step in and takeover (no matter how bad her driving is - j/k). Durban will be plentiful with food and rest. I am so keen on not having to cook for myself for a while, this year has been so hectic with that. Sometimes you miss the ease of residence, where food is prepared with or without you three times a day. It's not good food... but it's food that you didn't have to prepare yourself. But then again, residence had more than one "minus side".

Today is gonna be filled with doing things that need to be done before I leave. At least I don't have to pack up my room anymore, and leaving with the knowledge that everything will be exactly how it was when I left, is spectacular.

I've been thinking about ways to improve PuddleTV again. I'm sure I can come up with some awesome new ways to improve it, just need some time to think about it. Maybe the ability to make MPlayer show you whats coming up next? I use osd_cat to do my "messaging" to the viewer, it overlays on MPlayer so well, and because of it's customizability, I can make it stand out quite nicely. osd_cat is part of the xosd package. All you have to do is pipe any output to osd_cat and it displays it onto your X environment. So a way to make it show the next item coming up in the schedule shouldn't be too difficult, I will think about it over the holidays, as well as other ideas I need to implement when I get back.

Wednesday, July 06, 2005

Puddle TV - A product of boredom and genius

So Gorilla.scw was finally running, and was happily playing hours and hours of music videos continuously. This wasn't enough. I had no one to talk to except my PC... and Gorilla. I decided that it was time that Gorilla started doing something more useful, and not just blindly play music videos for the rest of eternity. My knowledge of a useful scripting language called Perl was very scarce, which forced me to use the simpler, more painful style of programming... bash scripting. I planned to make a couple scripts which played a variety of media, based upon a schedule which I would put into place via the use of the crontab.

The crontab is a type of event scheduler for *NIX boxes. The scheduler is called at certain specified times, and the script or program that is specified is run in the background. This is super useful for what I was wanting to do. The schedule would be exactly that, a schedule for the channel, detailing times to start programs. At first, it sounds pretty straight forward, and honestly, at first it was, but as soon as you start demanding more and more of the scripting, it becomes amazingly complex and complicated. The first huge obstacle I came across was having new events start running without just closing whatever was playing, but rather, wait until they have finished and then play afterwards, simulating a queuing system. This queuing system gave rise to a number of different scripts, each in charge of playing a certain type of video ie. music videos or movies or TV series. The queuing system was achieved through lock files, which would be 'touched' when playing was active and removed when playing was inactive. At the sign of no playing lock, the script would be able to play, knowing that nothing else is playing already.

Originally, this solution was outstanding, it performed exactly as I predicted, and seemed to make the queuing system work out quite efficiently. Unfortunately, with this queuing simulation, came the need for a certail hierarchy between all the different scripts. For instance, what happens if a movie is queued to play, but music videos are already playing. Here, the movie would wait for the music videos to finish before playing, but how does the music video script know that there is an even more important script waiting for airtime? I achieved this through the use of a "priority request" flag, which was set whenever a script of higher stature requested airtime. This way, the music video script would keep checking the flag, waiting to see if another script requested airtime, and in the case of a request, the music video script would play out the video until the end and then kill itself, removing the playing lock file, and "giving way" to the "priority request" script.

This worked out awesomely. The hierarchy was: Movie > TV Series > Music Videos. Music videos were at the bottom of the pile, which was ideal, because whenever neither a TV series, nor a Movie was playing, music videos would fill the "white space". That way, PuddleTV would never be idling and something would always be showing.

Unfortunately, (like with all scripts) something kept on bugging out and there were times when dead locks would occur with a race condition ocurring between two active scripts. Both would be fighting for the playing lock whilst one held the priority request. Suddenly, situations kept occuring where PuddleTV would be in a dead lock state with nothing playing. I came up with an idea to create a "check_idle" script which, through the crontab, would be called every two minutes. The script would check for the existence of the playing lock and/or the priority request, and then check whether MPlayer was running. If no mplayer was running, then it would mean that two scripts are fighting, and there needs to be some kind of intervention. The intervention would be to remove the playing lock and/or the priority request flag. This would cause both scripts to try grab the locks again, and because of the hierarchy and because of alternate waiting times between trying to grab the locks, the dead lock would be corrected, and the script with the highest priority would be granted airtime.

Eventually, I found a comfortable setting where no more dead locks ocurred, and the system ran fine for days without ever freezing due to a race condition. The system was brilliant, and after deciding on a daily TV schedule, I built the corresponding crontab file and started the system rolling.

After a couple hours watching PuddleTV, I realised the one main thing missing from the channel, compared to real world public TV channels, was advertising. I found myself missing the adverts between music videos or movies, as well as the advertising for up coming shows or the movies that are to appear that day/week. The solution was right in front of me: I had to create advertising on PuddleTV and some kind of way to let the viewers know about upcoming shows.

The first advert that was installed into the system was an advert showing the PuddleTV daily schedule. This was achieved by making a standard JPEG with all the details of showtimes in it, and then using mplayer, create an MJPEG of the picture repeating for a couple seconds. The schedule was shown over two different pages, one for morning/lunch viewing and the other for afternoon/evening viewing. Another necessity in advertising a schedule is to have some backing music to it. I used Audacity to cut some samples of equivalent running times as the schedule and then using mplex, I multiplexed the rendered video with the sampled audio. The results were incredible.

Soon after this, I figured out a way to advertise the movies for that particular day. Every day at midnight, Gorilla would randomize the list of movies and select two from it. The names of these two movies would then be pasted onto a template, using the convert command. This enables you to place text onto an image without actually placing it yourself in a graphics studio. After pasting the name onto the template, mplayer would create the MJPEG and mplex would multiplex it with some sampled audio, and then spit out two different AVI's, one for the 10AM movie and the other for the 8PM movie.

It was all good and well having these awesome scripts which would create movies (during runtime) and prepare them for airing on PuddleTV but there was no system implemented yet to decide when to play them, and how often. I started thinking about ways to decide when it will be appropriate to play adverts... obviously you don't want them too often otherwise it will be just like normal TV, but at the same time, you want the schedule to be aired every once in a while to show people whats up next.

The main scheduling of adverts would take place during music videos, because these would be playing the most, and the broken up nature of a whole lot of music videos would make slotting adverts in quite easy. I decided that the schedule should be shown every +- 8 videos, and advertising for the day's movies would happen every 8+(random(10)) videos. This would institute a kind of entropy with the advertising and not make it too structured. Another really cool feature I built in during a very lonely night was a stats page. The stats page would show you the current temperature outside, as well as maximum, minimum and wind speeds. It would also display the date and time, and the current load averages of Gorilla. This was done by a simple 'wget' of the local weather page, and then some fancy footwork to extract the relevant values. The stats were then pasted onto a stats page template the same way that the upcoming movies were, using convert, mplayer and mplex. The stats page also was also shown at random, iirc, about every 8-15 videos. Whenever movies or series were playing, the schedule and upcoming movies would be screened before and after every movie/series. I used some amazing backing samples from African Dope Records and Cape Town 2AM, both are local South African albums.

The upcoming movie script also had to be able to check what the time was, so as to avoid playing the advert for the 10am movie at like 2pm that day (after the movie had actually played). This was done by just performing a 'date' command and then cutting the relevant data from it, to check what the hour of the day is.

The scripts are now keeping themselves up to date by running a regeneration script every midnight. The script rebuilds the listings of movies/musicvideos/series to ensure that newly added media is also put into the loop. The use of these listings of available media was critical in making sure that the system ran smoothly and quickly, and that wait times between media playing on PuddleTV was kept to a minimum. With this system, the viewer rarely experiences an idle period of no more than 3 seconds, and if there is a deadlock, the viewer will only wait for under 2 minutes before the check_idle script is called to fix the deadlock (although, if the system is running untouched, this will rarely, if ever, occur).

After running PuddleTV for a couple days and once everyone was back in the digs, I could start getting some feedback and recommended addons. The one major noticeable problem was that certain music videos kept being played more often than others. It is so difficult to create completely random values constantly, without finding some kind of repetition of or "favourite" value. It sounds silly, but it was happening. It was quite obvious that some videos would keep coming up, far more often than others. The solution for this was quite simple: I made the music video script add the name of the song that it chose to a running list. The list would only ever be 100 lines long. As soon as it is filled, and another music video is added, the video on the bottom of the file would drop off. Each time a music video is randomly selected, the script would check if that name exists in the list, if it did, it would randomize another song and then check again, until it found a song that hadn't been played in the last 100 music video slots. This system seemed to work efficiently, and because it only ever had to deal with text files with music video names within it, the randomization and reselection would happen extremely quickly and completely transparent to the viewer.

The system is still far from perfect, I still want to implement some more advertising (real adverts, like the ones around the net that have been banned from TV), as well as more TV series. I also plan to make it more generic and more able to be ported across different computers. By making path names and other specific variables unset inside the actual script, other people could start to use my scripts to make their own PuddleTV, by just supplying the necessary directories containing the relevant media.

** All media discussed above have been obtained legally.

Gorilla.scw

Everyone left for holidays and such. I was left all alone in my digs. The product: Gorilla, and subsequently, PuddleTV (more on that later).

The idea has been floating around in my head for quite some time now. With all the media and random stuff on my PC, I could create some kind of continuous television programme on the TV in our communal lounge. At first, we played movies on the TV rather than sitting and watching it on a small computer screen, but it wasn't as easy as it sounds. To do this, I would have to move my whole PC through to the lounge, of course, switching it off (which any geek will tell you, is criminal) and taking the mouse and keyboard with it, plus extra AV cabling. This wasn't fun. And when you want to do it often, it becomes more of a pain than a pleasure.

The solution was simple: Using the spare parts I have lying around, create another stand-alone "dumb" terminal which can just play movies and nothing else. This was easy, first of all, I had tons of spare parts around my room from PC's that I've repaired and replaced over the last few years, and second of all, because our entire digs is on a switched network, it wouldn't need a big hard drive at all because all the media would be streamed over the network.

The end result goes by the name of Gorilla. The name was a randomly chosen word that Darb (my brother) gave the outstanding registered network address and so, the new machine,
Gorilla, was named. It's a Pentium-4 2.0 Ghz, with onboard network and audio. It carries a two gigabyte hard drive as it's primary drive and a one gigabyte drive as it's auxillary. Stacked with a mere 128Mb SDRAM PC133, and an old 32Mb RIVATNT2 AGP video card, it more than fits the requirements for playing standard compressed media.

The first obstacle was the operating system. Being a keen Gentoo Linux user, my first instincts were to install a base Gentoo linux system and then tailor it with some customized version of X and standard
MPlayer. Unfortunately, when seeking Darb's counsel on choice of OS, his opinions seemed to differ. He believed that a more desktop oriented flavour of Linux would suit Gorilla better, something along the lines of Ubuntu Linux. I am not a fan of Ubuntu. I have tried to use it before on our home PC in Durban, with no luck. I found that the simple desktop user requirements were not met, and simplistic things like connecting to the internet via a modem rather than a permanent DSL line, were verging on impossible. And if they're impossible for me as a long standing *NIX user, then how would the usual Joe be able to do it? Due to this, I was against the Ubuntu idea but because of it's quick installation times and relatively easy install procedure (as well as the respect I have for Darb's opinion) I decided to try it out.

I was unsuccessful. Dealing with such a small hard drive (2Gb) makes any standard Linux desktop installation difficult (but not impossible). Ubuntu states that it requires only 2gb for the normal installation, but when trying to perform this install, it ran out of disk space. This was Not Kief (tm). After a couple hours of toying with Ubuntu to make it install a less-fancy base, I threw in the towel and went with what I knew best, Gentoo.

Gentoo has it's pro's and con's. I'm a firm believer in Gentoo, and I still rate it as the best Linux distribution available. I have never liked Debian (the basis of Ubuntu) and I
have always enjoyed compiling and installing applications from source (the basis of Gentoo).

After pulling out of Ubuntu's install, and burning a copy of Gentoo's install CD, I was on my way. About 6 hours later I was settled in with a neat Gentoo installation containing all the required applications and 250mb to spare. Things were looking good.

Originally I wanted to build routing and bridging capabilities into Gorilla as well, so that he could take the place of our current router, Figlet. Figlet is a fine specimen, don't get me wrong, but her temperamental nature lends itself to being referred to as a female :-)

Gorilla was ready for launch, and after hooking it up to the TV (via a Digital to PAL converter), it was looking good. I samba mounted all my music videos onto Gorilla, and set it to play in a loop continuously, randomizing video choice, using MPlayer. Suddenly, the Puddle had a new music television channel.

Blogging Via Email

Testing blogging over email, using my handy Nokia N-Gage, and GPRS. It works :-)

Stir the Soup

I finally decided to start my own blog. I was thinking of hosting it on my universities local server, but instead, took the easy route and used blogspot. As soon as I'm blogging regularly, and I have the time next term, I will move it to a local, more personalized location.

The name of my blog comes from one of my many nick names here at Rhodes: Chicken. Thus, the ramblings on this blog are basically Chicken's soup of thoughts, therefore, Chicken Soup.

On Friday, me and my girlfriend Jen are trekking all the way up to my home town, Durban, basically for my mom's 50th birthday as well as for a nice ten day break at home. After that, we plan on heading up to Joburg for a couple days to stay with her mom, and sister. Should be great. I'm gonna blog about the project I'm currently working on at home, called PuddleTV real soon now, just want to test out this blogging facility first :-)