Educating the world

Our blog has over 10,000 readers a month

Editting the N900 custom dictionary

January 11th, 2011

Nokia’s N900 has quite a nifty way of helping you type. If you enter a word during an SMS, an email or on a web page it tries to predict what the word will be an gives you the option to auto-complete.

The phone has 3 dictionaries to help do this. The dictionaries have a precedence. As you type, the word is checked against the personal dictionary which is a list of words that you have only used a couple of times, these are generally recent words. If the sequence is not in there, then it is checked against the used dictionary which contains personal words that have been reused or selected from a previous auto-complete. If it isn’t in there it is checked against the uneditable system dictionary. As you type more letters you are more likely to get to the one you are looking for or the end of the word. If the end of the word was reached and the word is not a member of any of the dictionaries then it is added to the personal dictionary. Neat!

One of the problems with this is that the personal dictionary usually fills up with typos and it becomes really easy to turn those typos into used dictionary entries. Another problem is that the Nokia N900 didn’t have any way to edit the auto-complete dictionary other than to delete the dictionary files, switch off predictive text and switch it back on again (because it cached the dictionaries in memory). The files are located here:

/home/user/.osso/dictionaries/.personal.dictionary
/home/user/.osso/dictionaries/.used.dictionary

As you can imagine this was a pain. I started writing an App to edit these files for you and then I got wind of one that was hidden in the develop-extras repository. It’s been in there for a while and hasn’t changed so I think it’s pretty stable.

Here’s a few instructions on installing it from the developer’s extra software repository:

  1. Load in the App Manager.
  2. From Uninstall/Download/Update screen open the drop down menu.
  3. Select Application catalogues.
  4. Select New.
  5. Enter Catalogue name: Maemo extras-devel
  6. Enter Web address: http://reposityory.maemo.org/extras-develop
  7. Enter Distribution: fremantle
  8. Enter Components: free non-free
  9. Make sure the Disabled box is unchecked
  10. Then click Save.
  11. The phone will then check for updates and download the latest lists from all of the repositories.
  12. Click the Download picture in the centre of the Application Manager.
  13. Click the Utilities section button.
  14. Type “au” to narrow the search and Auto-Complete Editor will appear in the list.
  15. Click the App, say that you agree with the Terms and Conditions and click Continue.
  16. The App will download and install in a few seconds.
  17. The App will appear as AutoComp Edit in the App list.

Splitting an MP4 into 2 halves

December 15th, 2010

I recorded a friend’s stag do on a new video camera that produced a 4.5 GB video file. I wanted to stream this down to the telly and play it on the Xbox but the wifi bandwidth wasn’t quite beefy enough, so it was stuttery.

I then entered a world of hell trying to put it onto a removable media but none of that worked.

  1. First I tried to copy the 4.5GB on to a FAT32 memory stick, but the file system format wouldn’t take a file bigger than 4GB.
  2. Then I formatted the memory stick to NTFS which would accept the extra large file, but the XBox wouldn’t read this - weird thanks Microsoft!
  3. Next I thought of DVDs. ULead DVD burning software can only burn Joliet for the data file system and this wouldn’t accept the large file size either.

Then I had a brainwave - yes another one! - why don’t I just cut the large MP4 file in half! So simple. Went for a quick search on the internet. I really had not realised how much crud there was out there to do this. Everyman and his dog wants $34.99 for some (really) crappy application that splits an AVI or MPG file into pieces. I tried a couple and most either didn’t work or had a demo that only split the first 2 minutes, not to mention all the really dodgie warez sites that kept popping up.

Then I had another brainwave - why don’t I use FFMPEG it’s free. The first problem was to find a build of it that runs under Windows and the second problem is out of the gazillion different command line switches and options which ones will I need. So here follows the splitting MP4s guide for anyone who doesn’t want to pay $34.99 for someone’s school project.

If you run Linux then you should be quite capable of downloading the source from SourceForge, and compiling it up yourself, so you can skip to the FFMPEG command line section below. If you are running Windows or MacOs then you probably need a really simple guide so hopefully this should do!

You will need a copy of 7-Zip to uncompress the deliverable before you can run it.

  1. Go to: http://ffmpeg.arrozcru.org/autobuilds/
  2. Download the Latest static builds for MacOs or Windows.
  3. Use 7-Zip to unpack the file into a local directory.
  4. That’s it, there’s no installer!

Ok, now that the Linux boys/girl has re-joined us again we’ll talk about how you split an MP4 file into 2 halves.

From the command line enter the command:

ffprobe stagdo-1080p.mp4

This should produce the duration of the video file (I’ve highlighted it, because I’m nice).

FFprobe version SVN-r25924, Copyright © 2007-2010 the FFmpeg developers
built on Dec 10 2010 04:13:08 with gcc 4.4.2
configuration: –enable-gpl –enable-version3 –enable-libgsm –enable-pthreads –enable-libvorbis –enable-libtheora –enable-libspeex –enable-libmp3lame –enable-libopenjpeg –enable-libschroedin
ger –enable-libopencore_amrwb –enable-libopencore_amrnb –enable-libvpx –disable-decoder=libvpx –arch=x86 –enable-runtime-cpudetect –enable-libxvid –enable-libx264 –extra-libs=’-lx264 -lpthrea
d’ –enable-librtmp –extra-libs=’-lrtmp -lpolarssl -lws2_32 -lwinmm’ –target-os=mingw32 –enable-avisynth –cross-prefix=i686-mingw32- –cc=’ccache i686-mingw32-gcc’ –enable-memalign-hack
libavutil 50.34. 0 / 50.34. 0
libavcore 0.16. 0 / 0.16. 0
libavcodec 52.99. 1 / 52.99. 1
libavformat 52.88. 0 / 52.88. 0
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.68. 1 / 1.68. 1
libswscale 0.12. 0 / 0.12. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ’stagdo-1080p.mp4′:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.56.0
Duration: 02:28:07.92, start: 0.000000, bitrate: 4567 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 1920x800 [PAR 1:1 DAR 12:5], 4400 kb/s, 23.98 fps, 23.98 tbr, 2997 tbn, 47.95 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 159 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00

From the example we can see the video is 2 hours 28 minutes 7 seconds and 92/100th of a second. We want 2 halves so divide by 2, if you want thirds you’ll have to divide by 3, if you want quarters…. just kidding!

A bit of arithmetic and we can work out the start and end times of each section you would like to copy out of the main MP4 file.

FFMPEG only ran on one of my 8 cores so if you open 2 command line boxes you can run them at the same time on different cores, so it took the same time to decode both halves as it would have done to decode one half.

ffmpeg -i stagdo-1080p.mp4 -ss 00:00:00 -t 01:04:06 -vcodec copy stagdo-1.mp4
ffmpeg -i stagdo-1080p.mp4 -ss 01:04:06 -t 01:24:06 -vcodec copy stagdo-2.mp4

      -i - input file name. I used MP4 but FFMPEG supports many different video and audio file formats.
      -ss - start time in hours, minutes and seconds.
      -t - time or duration in hours, minutes and seconds.
      -vcodec - video codec to use. We use copy which just copies the data exactly as it’s written.
      Finally the name of the output file.

For completeness here is the output of what the FFMPEG looks like:

FFmpeg version SVN-r25924, Copyright © 2000-2010 the FFmpeg developers
built on Dec 10 2010 04:13:08 with gcc 4.4.2
configuration: –enable-gpl –enable-version3 –enable-libgsm –enable-pthreads –enable-libvorbis –enable-libtheora –enable-libspeex –enable-libmp3lame –enable-libopenjpeg –enable-libschroedin
ger –enable-libopencore_amrwb –enable-libopencore_amrnb –enable-libvpx –disable-decoder=libvpx –arch=x86 –enable-runtime-cpudetect –enable-libxvid –enable-libx264 –extra-libs=’-lx264 -lpthrea
d’ –enable-librtmp –extra-libs=’-lrtmp -lpolarssl -lws2_32 -lwinmm’ –target-os=mingw32 –enable-avisynth –cross-prefix=i686-mingw32- –cc=’ccache i686-mingw32-gcc’ –enable-memalign-hack
libavutil 50.34. 0 / 50.34. 0
libavcore 0.16. 0 / 0.16. 0
libavcodec 52.99. 1 / 52.99. 1
libavformat 52.88. 0 / 52.88. 0
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.68. 1 / 1.68. 1
libswscale 0.12. 0 / 0.12. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ’stagdo-1080p.mp4′:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.56.0
Duration: 02:28:07.92, start: 0.000000, bitrate: 4567 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 1920x800 [PAR 1:1 DAR 12:5], 4400 kb/s, 23.98 fps, 23.98 tbr, 2997 tbn, 47.95 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 159 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
Output #0, mp4, to ’stagdo-1.mp4′:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.88.0
Stream #0.0(eng): Video: libx264, yuv420p, 1920x800 [PAR 1:1 DAR 12:5], q=2-31, 4400 kb/s, 2997 tbn, 23.98 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 64 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=92212 fps=251 q=-1.0 Lsize= 2044520kB time=3845.97 bitrate=4354.9kbits/s
video:2011880kB audio:30079kB global headers:0kB muxing overhead 0.125418%

Each 1 hour 4 minute (and 6 second) section took about 6 minutes to copy. Once the files were split they both fitted on my FAT32 memory stick.

The first half played very happily on the XBox, but unfortunately the second half was about 0.25 seconds out of audio sync, so if anyone knows what I can do to adjust the audio, I’d be grateful if they would leave a comment.

Laptops and PC desktops

December 9th, 2010

Being in I.T. means you suffer from the same problems as doctors - bare with me on this! You meet a doctor at a party and the first thing you ask is are you a GP (General Practitioner) as opposed to some weird area of medicine or biology, or even English literature (Phd) that you are going to know nothing about. If they say they are a G.P. then the second question is usually along the lines of “I’ve got this spot/growth/whatever” or “I’ve had this pain in my whatever” and the party for them turns into another day at the clinic.

Well being in I.T. can be a bit like that only it tends to be “I’ve got this problem with my soundcard” (if you were around in the 80s) or “I think I have a virus, can you fix it?” or “What is the best computer to buy?”

Well I thought I’d answer the final one here so I can refer the friends of friends away from me and towards my blog so I don’t have to talk to them any more.

First you must ask yourself if you would like a laptop, a desktop or dare I say it…. a tablet.

When you say “tablet” everyone thinks of the iPad but it depends on whether you are a form over function type of person who has bought into all the hype. If you are then you are only reading this article to hear someone say how wonderful they are, and you won’t find that here, so you might as well stop reading now. If you are a realist there are plenty of other laptops which are tablets as well, like the Dell Inspiron Duo. Tablets have come a long way in recent times so anything that supports the Android operating system will keep you happy. I quite like the ASUS Eee Pad which is a cross between a tablet and a netbook.

So now we are on the question: laptop or desktop?

These days there aren’t too many reasons why you would buy a desktop rather that a laptop. Now-a-days you can plug a bigger screen or keyboard into the laptop to make a desktop set-up. Laptops are generally more expensive, easier to steal and slightly slower.

For someone who is only interested in surfing/email/office, all computers these days are good enough. You won’t notice the difference between the top of the range and the bottom of the range. If you already have a computer the chances are that it is a couple of years old and has lost it sparkle. Literally, anything new will be about 10 or 20 times faster and better than what you currently have. It will be capable of running the operating system it comes with without any problems.

The main advantage of a laptop and a desktop is mobility; being able to carry it from the sitting room to the kitchen adds up to a more convenient experience.

Pretty much all laptops these days are much-of-a-muchness. When buying a laptop you just need to ask a couple of questions: does it look nice? is it nice to type on? is it not too heavy? The best way to answer these questions is to go somewhere like PC World or Comet and have a play. Pick something you like!

Python 2.7 modules

November 24th, 2010

Python 2.7 was released on 3rd July 2010 and surprisingly there is still almost no support for it in major projects; I am constantly surprised.
One of the problems (IMO) with Python is that a supporting Python module needs to be specially compiled against the end main version of Python. In other words modules like, LXML for Python 2.6 is incompatible with Python 2.7 so it just won’t work. PyPy is a project set up to address this. PyPy is basically Python written in Python - yeh, I know!

I started learning Python recently and I had to make a choice. do I go for:

  1. Python 2.6 which is well established had loads of supporting modules but has been superseded by Python 2.7
  2. Python 2.7 which has been out for 6 months, has less supporting modules, but has newer language built-in modules or
  3. Python 3.1.2 which has even less support than Python 2.7 and has slightly different language semantics.

Normally, I’d go for the latest and greatest, but all my Python buddies told me to avoid it at all costs, mainly due to poor support for everything. The company I’m currently working at is a 2.x shop so I chose the latest version of that which is Python 2.7.

Working on various projects I needed various support modules but couldn’t find them so I had to compile them up myself. So in true open source fashion I have publish them here for others. In each case I’ve tried to give them to the project owner but blar, blar, blar.

The Console Module 1.1a1
The Console module provides a simple console interface, which provides cursor-addressable text output, plus support for keyboard and mouse input
[ Documentation | console-1.1a1-20011229.win32-py2.7.exe ]

LXML 2.2.8
lxml is the most feature-rich and easy-to-use library for working with XML and HTML in the Python language
[ Documentation | lxml-2.2.8.win32-py2.7.exe ]

omniORBpy 3.5
omniORB is a CORBA library and omniORBpy are the Python bindings for it.
[ (My) Documentation | Documentation | omniORBpy-3.5.win32-py2.7.zip ]

Found a pretty good repository for Python extensions at:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

Whitelists in GMail

November 18th, 2010

Are you finding that GMail is sending some of your friend’s email to the spam folder? Well this is the post for you. A couple of simple steps will see you right.

  1. Login to the web interface.
  2. Click the Settings link at the top right of the screen.
  3. On the Settings page click the Filters tab.
  4. Click the Create a new filter link at the bottom of the page.
  5. Enter the email address of your friend in the From field.
  6. Click the Next Step button.
  7. Check the Never send it to Spam box.
  8. If you want to pull all the previously spammed emails out of the spam folder you can check the Also apply filter to [x] conversations below (where [x] is some number).
  9. Click the Create filter button.

Then you’re done, Simples!