Tag Archives: howto

How to watch videos on a Nokia smartphone

The Nokia N96 smartphoneMy new Nokia N96 (yes, and then they immediately released the N97!) may not be as intuitive as the iPhone but is packed with far more features and is so much more open to exploration that it’s a keeper. Not only that but clever @LonelyBob gave me some help last night to fix a problem I’d been battling with – video conversion.

Like him, I tried MEncoder which (unusually) didn’t do the trick and then gave FFmpeg a go. As usual, it requires a load of options and arguments that I don’t fully understand but converts almost any format into any other format – in this case an MP4 file. Trouble was, everything I tried resulted in a playback error on the phone. After exhaustive searching it seems the MP4 needs to be in a mobile-friendly wrapper for which I used MP4Box, found in the “gpac” package on Linux. That worked nicely but the extra step is a hassle. Enter @LonelyBob and his magic one-liner. I edited it a bit for my version of FFmpeg (3:0.svn20090303-1) and this is what’s left:

ffmpeg -y -i input.mkv -vol 256 -acodec libfaac -ac 2 -ar 44100 -ab 64000 -f 3gp -vcodec mpeg4 -s 320x240 -r 25 -b 256000 output.mp4

Of course, input.mkv can be almost any type of video file. The resulting output file is small but not great quality so you could try changing the bitrates, etc. to something like:

  • -ab (audio bitrate): 96000
  • -b (video bitrate): 384000
  • -s (dimensions): 320×176 (for widescreen)

N.B. If you get an “Unknown encoder: libfaac” message, try using “-acodec aac” instead.

Oh, and it’s worth the effort – the N96′s screen is fantastic.

How to do alphanumeric validation with PHP

Hardly worth a whole blog post but it may help somebody…

is_numeric() is the function to use for validating numeric-only user input with PHP but unfortunately there is no is_alphanumeric(). Or so I thought.

Meet ctype_alnum()

Here’s an example of its usage:

if (ctype_alnum($_POST['username'])) {
    echo "Thanks - that's a good username.";
} else {
    echo "The username must contain only letters and numbers.";
}

I’ve seen lots of people using regular expressions to get round this, myself included, and it’s not complicated but it’s still nice to simplify where possible.

How to input Japanese in Opera on Linux

UPDATE: As of 2010, Ubuntu and Fedora both use iBus and I must say this is a great addition to the IME landscape. As Jacob7908 suggested in the comments, this is my new recommendation.
——
Like many Linux users I’ve never really had much luck with SCIM and Opera but I’m pleased to say I’ve finally found a solution: use UIM.

I’ve seen suggestions to install scim-bridge-qt (most promising), uninstall scim-bridge and start a second instance of SCIM just for Opera. None of these worked for me but I found a suggestion to use UIM instead which did the trick. Here’s what you do:

1. Install Anthy and UIM

2. Add this to the top of your .xinitrc file or equivalent (e.g. .xsession) in your home directory.

export GTK_IM_MODULE="uim"
export QT_IM_MODULE="uim"
uim-xim &
export XMODIFIERS=@im="uim"
uim-toolbar-gtk &

The optional last line launches a toolbar which you right-click to edit preferences, for example your key-bindings.

3. Logout and login again, launch Opera and enjoy.

If you have a Japanese keyboard you may need to add this line to the top of the .xinitrc file to make UIM detect the Hankaku-Zenkaku key on the left.

This works at least on Arch Linux. Please leave feedback if it doesn’t work for your distro or if you have other suggestions.