I’ve got two heads!

I’ve been meaning to do it for a while, but I’ve finally bought myself a second head! No, not one to go on my neck, Zaphod style, but another LCD monitor on my computer.

Two heads are better than one!

This means that I now have to monitors side by side, with the ability to simply move my mouse from one to the other. It makes using my computer a lot easier. I can just keep my email and such like open on one screen, and carry on my work on the other. Windows can be picked up from one screen and dragged over to the other, even being left in the middle of the two, tho’ this makes it harder to use due to the surroundings of the monitors.

Both monitors are the same model. I got one last year to replace my old one that seemed to be getting watermarks on it and have been very impressed with it. The model is AG Neovo F419, and I may well be getting another one for full triple header wonderfullness!

Setting this up is very easy, just needing a couple of extra configuration parameters in the X config file. I’m using a GeForce Quadro 4 card with Dual DVI outputs which gives fantastic performance. Running glxgears gives me 1900+ FPS, even when the gears window is moved from screen to screen.

Changes needed to get it working were in the /etc/X11/xorg.conf file under Kubuntu 6.06 in the ‘Device’ section for the graphics card:

Section "Device"
        Identifier      "NVIDIA Corporation NV28GL [Quadro4 980 XGL]"
        Driver           "nvidia"
        BusID           "PCI:1:0:0"
        Option          "NvAGP" "1"
        Option          "RenderAccel" "true"
        Option          "TwinView" "true"
        Option          "MetaModes" "1280x1024,1280x1024;1024x768,1024x768"
        Option          "TwinViewOrientation" "DFP-0 LeftOf DFP-1"
        Option          "ConnectedMonitor" "DFP,DFP"
EndSection

The magic lines are from the ‘TwinView’ option down. TwinView basically makes the two screens act as one extra long one as far as the computer and the window manager are concerned. The ‘MetaModes’ line then splits the new big screen back into two smaller ones. It does this so that things that know how to handle seperate monitors can program them both seperately such as allowing different wallpapers etc. It also makes sure that 3d games don’t try and use both screens, which with only two monitors means that, for example in FPS games, the view point is right in the middle of the two monitors. The ‘TwinViewOrientation’ simply tells the computer where the two monitors are in respect to each other so that you can place the second one on the left or right of the main one. The last line ‘ConnectedMonitor’ should not really be needed, being auto detected, but I put it in just to make sure. It simply says that the two monitors connected are digital flat panels.

All in all the setup took about 20 mins from getting the monitor out of the box, wiring it up (realising that my original monitor was actually connected to the second output, so had to switch them round), getting the brightness and contrast set to the same on both monitors (quite important to make it look good, and very easy to do with identical monitors) and reconfiguring X.

I’m definately going to look into getting a third one at some point, but I’d then need a second PCI graphics card. Or maybe I’ll take the chance to upgrade my PC and get a PCI-X based system with multiple graphics cards! 🙂 I’ll also have to rearrange my cellar to fit 3 monitors on my desk!

Asterisk and a Linksys SPA-941

Linksys have done it again, produced an excellent product with a build quality to rival Cisco’s main offerings. I’ve just become the proud owner of a shiney new Linksys SPA-941 VoIP hardphone.

Getting it out of the box, it looks like its come from the same heritage as many of the Cisco VoIP phones, which isn’t surprising seeing as Cisco aquired Linksys about 3 years ago. It has a solid feel to it and the buttons respond nicely, unlike by Grandstream BT-100 which feels rather (very) cheap in comparison.

The next model up, the SPA-942 comes with a backlit display and an extra ethernet port, but neither of these were a major problem for me.

Getting the phone working with Asterisk was a total doddle. I already had a sip account set up in Asterisk, so I simply plugged the phone in to the network and power. The phone got a DHCP address (which you need to lookup what IP address it gets given) and I went to the web administration page with a browser. All that had to be done was set up the username, server address and password, then apply the changes. The phone rebooted and was online with Asterisk ready to make and receive calls.

I’ll write up the configuration at a later date. I’m going to see if I can write up some instructions for doing an autoconfiguration process for rolling them out at a commercial site.

Other Links:

 

Kubuntu Linux on an Apple G4 iBook

I’ve been using my iBook for nearly a year and a half now with Mac OS X. Whilst the hardware is fantastic, I’m not that impressed with OS X. Hardware support is of course spot on, but usability wise it leaves a lot to be desired. I know a lot of people swear by it, but I still prefer the more classic window systems such as KDE. I even find Windows easier to use!. To this end, I was contemplating buying a new laptop to put linux on as a replacement to the iBook. That was until I happened to notice that there were open source drivers for the Airport Extreme wireless cards that the iBook uses. This is a bit of a god send seeing as most laptops that I have been looking at have either poor battery life compared to the iBook, or are a bit out of my price range.

This entry is my documentation for installing Kubuntu on an iBook, which has given my trusty ol’ iBook a whole new lease of life. I chose Kubuntu as I have recently been a bit of a Debian convert, and I have been using KDE for a long long time and it has now become my desktop distribution of choice (with Debian on the servers of course!)

The first step is to download the Kubuntu 6.06 PowerPC CD image and burn it. This can be found on www.kubuntu.org.

Next, install the standard Kubuntu onto the iBook. To boot up from CD, press the ‘c’ key as the iBook turns on and you hear the gong. Installation is rather straight forward and just the same as installing Kubuntu on just about any hardware. You will need to have the iBook plugged into a network cable during the installation seeing as drivers for the wireless card need to be downloaded seperately.

Once Kubuntu is installeed, all that needs to be done is getting the wireless working. Only two commands are really needed to do this. One to download a package, and one to install it!

wget http://ubuntu.cafuego.net/pool/dapper-cafuego/bcm43xx/bcm43xx-firmware_1.2-0ubuntu1_all.deb
sudo dpkg -i bcm43xx-firmware_1.2-0ubuntu1_all.deb

Hopefully, that should be it. For more information on the wireless drivers, check out the Ubuntu Wiki page for bcm43xx. Reboot to make sure that everything is ok and then you can use all the standard tools to connect to wireless networks. Personally I use KNetworkManager which seems to work fine. I’ve been using my iBook and Kubuntu for a few days now and not come across any major problems. Bluetooth works well, the sound card gets detected automatically, and the function keys work to control volume and brightness.

The only slight niggles I’ve found are that it takes about twice as long to come out of hibernation as it did with Mac OS X (still, quicker than most systems I’ve seen, so not much of a niggle) and I can’t seem to get the wireless to come up automatically after going into hibernation, tho’ I’ll probably be able to overcome that soon. The other niggle is on the hardware… Where’s the right hand mouse button! 🙂 F11 and F12 are set up as middle/right mouse buttons by default under Kubuntu.

there’s still a few things that I haven’t tested on it such as graphics performance and some of the addons, but they aren’t important for what I need it for.

All in all, this has got to be the best laptop system that I’ve owned, and installing Linux onto my iBook has given it a whole new lease of life!

MythTV and a Sony PSP

I’m not really much of a gamer, but after having a go on someone’s PSP, I had to get myself one. They are a wonder of modern technology. A small package that crams just about everything you could want to play games, and more besides. It is sold as a games machine, but it makes a pretty good all round portable multimedia system, playing movies, MP3s and holding your holiday snaps on there too!

Most of the functionality is easy to get to work with linux. Basically it is seen as a mass storage device and files can be copied to and from it with the usb cable. The one area that is problematic under linux is movies. Sony have decided to only support an MP4 media format, and even then it has some strange headers so that only certain MP4 files will play. There’s plenty of information out on the net for converting these files, but it can be hidden in various different sources. I’ve written this article to draw together all those sources into one place. I’ve tried to credit the original supply of the information wherever possible.

First step is to get a working copy of ffmpeg that supports the PSP format. This isn’t as easy as it sounds. I ran into problems with the version of compiler I was using. Most up to date distributions ship with gcc4, which will not let you compile the ffmpeg that you need. On Mandrake and Debian, they also ship a version of gcc3, but unfortunately this has a bug in it which means that you will get halfway through the compile and it will crash. In the end I downloaded the source for the latest version of gcc3 (3.4.5) and compiled that. On Mandrake you change the symlink in /etc/alternatives/gcc to the version you want to use, in Debian the symlink is in /usr/bin/gcc

Feel free to try with the version of compiler you have, but if you have any problems then just get the latest version of gcc3. It may be worth trying seeing as it takes a rather long time to compile gcc!

A few other libraries are needed to get this working, but I found the default ones in Mandrake 2006 to work fine, YYMV. The libraries needed are the libfaad, libfaac, libogg and libvorbis. Don’t forget to get the -devel packages for these (-dev under debian).

Once you are ready to compile, I found the best instructions on the linux PS2 site, in a post by “cronocloud“. Here is the basic gist of the post.

Get a snapshot of the ffmpeg CVS from the 10th March at: http://www.nurs.or.jp/~calcium/3gpp/sources/ffmpeg-050310-0.30.tar.gz, along with a patch from: http://www.nurs.or.jp/~calcium/3gpp/sources/ffmpeg_patched_diff_031.tar.gz.

Uncompress the ffmpeg and patch tarballs into the same directory. Next move the file libavformat/movenc.c from the patch into the ffmpeg/libavformat directory, overwriting the existing one. Then, open the file in an editor and find the section (near the top) that looks like:

#ifdef WIN32_PSP 
 #include "wchar.h" 
 #include "locale.h" 
 #include "windows.h" 
 #endif

Replace this with:

#ifdef WIN32_PSP 
#include "wchar.h" 
#include "locale.h" 
//#include "windows.h" 
 
#define CP_ACP 0 
#define MB_PRECOMPOSED 0 
size_t MultiByteToWideChar(int a, int b, char *src, size_t c, wchar_t *dest, size_t n) { return mbstowcs(dest, src, n) + 1; } 
#define _timezone 0 
#endif

Edit the file ffmpeg/libavformat/Makefile and remove the line:

OBJS+=avisynth.o

Edit the file ffmpeg/libavformat/allformats.c and remove the line:

avs_init(); // [MobileHackerz]

Lastly, edit the file ffmpeg/ffmpeg.c and remove the lines:

setvbuf(stdout, (char *)NULL, _IONBF, 0); // [MobileHackerz] 
setvbuf(stderr, (char *)NULL, _IONBF, 0); // [MobileHackerz] 
_setmode(_fileno(stdout), _O_BINARY); // [MobileHackerz]

Once all this is done, run a configure and make in the main ffmpeg directory. This should go away and compile ffmpeg (hopefully). The configure line to use is:

./configure --enable-gpl --enable-faac --enable-faad --enable-vorbis --enable-ogg

By now, you should hopefully have a ffmpeg binary that will convert just about any movie format into one that can be played on your PSP. Unfortunately, ffmpeg is not the simplest of programs to use, and needs 101 command line options to be specified. I’m not exactly an expert when it comes to video formats, so a lot of these options I specify below come from the “monkey see, monkey do” school of thought! The following is an example of how to convert a NUV video (the kind used in MythTV) to a PSP MP4 format.

./ffmpeg -y -i /home/mythtv/Recordings/1010_20051213180000_20051213183000.nuv -title "The Simpsons - Brothers Little Helper" -bitexact -f psp -s 320x240 -r 29.97 -b 768 -acodec aac -ac 2 -ar 24000 -ab 32 -map 0:0 -map 0:2 ~/M4V00070.MP4

This will take the file and encode it to an output file ~/M4V00070.MP4. The filename must be in this format for the PSP to pick it up. (M4V followed by 5 numbers, ending with .MP4 – All characters must be in upper case). Some options are straight forward (-title!) some others can be tweaked. The frame rate (-r) should be either 29.97 or 14.985. I’ve not been able to get any other rates working. The bitrate (-b) should be either 384 or 768, depending on what type of quality you want. -f specifies the output format is psp (duh!), -acodec is the audio codec to use (aac) and the -map options at the end are so that the audio works with NUV videos (probably not needed for other movies).

The last step I did was to take a script that I found on the MythTV website and extend it a little. Thanks to james at mauibay for the initial script. Extensions on mine include, automatic tracking of movie number, to always create unique movies, and creation of a thumbnail. Also it will produce a log file so you can check on why things went wrong. This script can then be added as a user job in MythTV so that it can be fired off on any recording, or automatically on all.

#!/bin/bash

FILE=$1
TITLE=$2

FFMPEGBIN=/home/mythtv/bin/ffmpeg
OUTDIR=/home/mythtv/PSP
declare -i FILENUM=`cat $OUTDIR/.filenumber`

OUTFILE="M4V`cat $OUTDIR/.filenumber`.MP4"
OUTTHM="M4V`cat $OUTDIR/.filenumber`.THM"

echo "Encoding" > $OUTDIR/.$OUTFILE.log
echo "Input file:  $FILE" >> $OUTDIR/.$OUTFILE.log
echo "Output file: $OUTFILE" >> $OUTDIR/.$OUTFILE.log
echo "Title:       $TITLE" >> $OUTDIR/.$OUTFILE.log

let FILENUM=$FILENUM+1
printf "%05d" $FILENUM > $OUTDIR/.filenumber


$FFMPEGBIN -y -i $FILE -title "$TITLE" -bitexact -f psp -s 320x240 -r 29.97 -b 768 -acodec aac -ac 2 -ar 24000 -ab 32 -map 0:0 -map 0:2 $OUTDIR/$OUTFILE >> $OUTDIR/.$OUTFILE.log

$FFMPEGBIN -y -i $FILE -title "$TITLE" -s 160x90 -padtop 16 -padbottom 14 -r 1 -t 1 -ss 3:00.00 -an -f singlejpeg $OUTDIR/$OUTTHM >> $OUTDIR/.$OUTFILE.log

When setting the MythTV job, don’t forget to put quotes round the title setting!

Hopefully this is easy to follow and has all the information in one place. If you need any more help or know of anything missing from my explanation, feel free to drop me a line.