Nokia N97 v20 firmware update requires Windows

Rant alert!

I was so pumped for this new firmware. Anything that makes my phone run better is a good thing. It’s even better when I can actually install it though! What the crap?!?! That’s right I can’t install it. Nokia is only distributing it initially for installation through their software updater that’s tied to some Microsoft Windows ™ software. Check out the release announcement in the Nokia forums.

Seriously? I’m not sure I follow the logic behind only distributing the update exclusively through the Windows ™ updater initially. Aren’t people running Windows ™ the ones that never update their software anyways? (ouch) The phone has a built in software updater for goodness sake! Sure it’s a big update (they list this as the reason it’s not distributed over the air yet) but so what!?!? I updated my firmware to v12 over the air the same day I bought the phone.

Gah! waiting != cool. For shame Nokia, for shame.

The Joys of Inheriting an Old Web Site

Recently I’ve been helping out a buddy of mine with a website he’s recently taken over. I’ve taken on hosting it and I’m helping getting some “best practices” into their development process. I’m no veteran of open source but I’m a long time spectator (some would say a lurker) so I figured it would be a good learning experience for the both of us.

When we took over the code was pretty much just dumped on our laps. We got a tar ball of the code (well the whole site really), a database dump, and a pat on the back. No install script, no documentation, just 53000 lines of PHP, some HTML and some users … great. We didn’t even know how much PHP code there was beyond a file count till I wrote a little script to count the number of lines of code in the PHP files. This script probably gives an inflated sense of code size since it doesn’t account for comments, whitespace or in line HTML. It’s probably safe to say the line count is a few thousand lines heavy but it’s a good estimate (better than what we started with).

find ./ -name '*.php' | 
  while read FILE; do
    SUM=$((SUM+$(cat $FILE | wc -l)));
    echo $SUM;
  done;

Simple right? But pretty useful. I had initially tried to replace the cat $FILE | wc -l with just a wc -l $FILE but I guess wc prints the file name after the line count and I couldn’t figure out how to turn this off. Meh, take the file name away from wc and all is well.

So this how it all started. I’ll be posting periodically as interesting things happen with this project. I’ll post useful scripts, whatever interesting PHP stuff I pick up along the way and anything else that may be interesting. The code is pretty old (dates on some files go back to 2003) so this should be interesting. I’ve even spotted a few frames on the site … yeah.

I’ll try to be constructive as much as possible but I can’t guarantee that I won’t post a few WTFs as I go through the code and find ’em … bad coding makes for good comedy (to the right audience or course).

Stay tuned.

Minimal GStreamer App

So in my last post (way back when) I was talking about transcoding some video. I wanted to use GStreamer to do the job but HandBreak was so much easier (pretty cool app too). So after I got the transcoding working with HandBreak I started playing around with GStreamer to see what it would take to code up a small app to do the job.

The first thing is just to code up a little bit of C to get the video playing. The GStreamer part here is pretty simple. It’s just like the gst-launch command I laid out in my last post. I’ve added a few bells and whistles to get command line parameters and to do some input validation. I’m using as much glib as I can for practice.

The result is a pretty short (for C) application that is a bare-bones GStreamer media player. Naturally you’d want a few additional things from a media player but that’s not our end goal. We want to take the playbin (or something like it) and hook it up to another pipeline of our own design that will encode the video & audio for our specific purposes. This is what’s coming up … soon hopefully. Honestly with the class I’m currently taking at SU it may be a while.

For now read the code and enjoy. It’s available for download below. I even made a Makefile for ya.

Download: gst-play-min.tar.gz

Video transcoding for the N97

A big part of why I bought the N97 was the media player. It has some pretty impressive specs: supports the h264 and MPEG4 codecs, the mp4 and 3gp containers, AAC audio … so yeah that’s pretty sweet. First thing I did when I got the phone all charged up was go into the old media library, copy over a file I thought met there specs and load it up into the media player. Yeah it definitely didn’t work.

Upon closer look there are some constraints I wasn’t meeting and unfortunately some bugs I didn’t know about. Let’s start with what I was doing wrong.

First off the constraints on the video dimensions are 630 by 320 pixels. Anything over this won’t play, the phone won’t scale the image down. So we’ve gotta convert the video, no getting around that. First thing I did was look into using GStreamer. I wanted to mock up a pipeline and throw it at gst-launch to do the transcoding. First thing I did was break out the playbin to do the decoding:


gst-launch-0.10 playbin uri:file:///path/to/vid

This does some GStreamer magic detecting all of the media file’s attributes and builds a pipeline in the bin to do the decoding. If you execute the above the bin will build default sinks for both the audio and video streams which will basically play the file.

Now it’s a matter of linking the audio and video streams from the playbin to a pipeline, simple right? I couldn’t figure out a way to do this from gst-launch. In fact I found a mailing list post indicating that this can’t be done through gst-launch. So now it’s build my own application or find one that already does this. As much as I like rolling my own, this is no small feat.

Coincidentally I’m at LinuxCon this week and I ran into another guy with the same phone. He pointed me to HandBrake. That was the ticket. This app has a great CLI interface and supports the codecs we need. It also has some built in profiles for popular devices.

My goal was to produce transcode to h264 at 630×320, AAC (don’t really care about bitrate etc) in an mp4 container. The HandBrake iPhone profile comes pretty close with a few minor modifications:


HandBrakeCLI -i ./infile.avi -o outfile.mp4 -e x264 -q 0.589999973773956 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 --maxWidth 640 --maxHeight 320 -m -x level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1

This is a pretty compute intensive task. On my laptop it maxed out both CPUs for about a half hour for a 24 minute TV episode. In the end I had an mp4 file that was about 150MB with the desired attributes. Playing it with Totem was successful. The properties menu showed all the attributes were as expected and it looked great. Success?

Not quite. Turns out my N97 still couldn’t play it. The media player just threw up an error, wouldn’t play audio or video. I spent a while playing around with the parameters for the x264 encoder (on a much smaller file) but wasn’t able to get the phone to play any h264 encoded video. On a few occasions it would play the audio but never the video.

So h264’s out and MPEG4’s in. After getting rid of the h264 stuff from the above command I ended up settling on something like this:


HandBrakeCLI --input ./infile.avi --output outfile.mp4 --encoder ffmpeg --rate 24 --audio 1 --aencoder faac --ab 128 --arate 48 --mixdown dpl2 --format mp4 --maxWidth 640 --maxHeight 320 --markers

That’s the trick. Originally I had included the quality flag form the h264 command line. This produced a super small video file, 3.5 times smaller than the original but the video produced looked kinda grainy. Since I’m not pressed for space on my phone yet (32GB of storage is a lot of space) I dropped the quality flag and let it run presumably at 100%. This produced a file about 25MB smaller than the original (likely attributable to the decreased image resolution) with excellent picture quality. Better yet my N97 played it perfectly.

Conclusion: looks like the h264 implementation on the N97 isn’t all it’s cracked up to be. This is likely a bug. So for now, stick to MPEG4 through HandBrake and enjoy some videos on your N97. The new firmware update (v20) has been in the Nokia press recently but I haven’t seen anything about fixing h264 support. Meh.

“Web: No gateway reply” Nokia N97 fix

Better late than never here’s how I got around that pesky “Web: No gateway reply” error message when using my N97 with the WiFi at my house.  Initially the wireless would work but after a while I started getting the error messages.  I took a lucky guess and figured the phone was doing some power saving stuff that was screwing up the link between it and my router.

Seemed reasonable to try to turn off any WiFi related power saving stuff and see if this made any difference.  This setting is buried so you’ll have to go to


Menu > Settings > Connectivity > Wireless LAN > Options > Settings > Options > Advanced Settings

You’ll get a warning messaging when you open the Advanced Settings that says

Changing advanced settings is not recommended. Continue anyway?

If they hide the configuration under a dozen dialog boxes and recommend that you don’t change it, you probably should … just a rule of thumb. Anyways, scroll all the way down to the bottom and you’ll find the “Power saving” configuration.  By default mine was enabled but after disabling it I’m able to use the WiFi in my house quite reliably.

Sorry for the lack of screen shots but it looks like there isn’t a good screen capture application for the N97 yet.  That combined with the convoluted process to get a developer certificate to sign the program before installing it was enough to deter me for now … I’ll get to it eventually 🙂

Getting started: Nokia N97

My Samsung BlackJack II with Windows Mobile 6 finally got to me.  I have never hated an electronic device the way I hate this phone.  But before I digress into a rant I’ll just say this: never buy a phone with Windows on it.  Windows mobile has all of the features of Windows 95 with the stability of Windows ME.  Towards the end of it’s miserable life my BlackJack would just turn off for no reason other than that it knew how worthless it was and was tired of leading such a pointless existence.  Better yet, AT&T sold me this phone and provided me with absolutely no support … thanks guys.

But the good news:  I replaced it with an UNLOCKED Nokia N97.  In comparison, this phone is heaven on earth.  I’ve managed to play around with most of the features that I consider essential:  music player, web browser, Wifi.  The pundits have given this phone some really rough reviews so I’ve gotta post some positive stuff since my experience has generally been good.  Here goes:

First things first is updating the firmware.  Nokia has fixed a bunch of bugs related to the interface so having the latest software is a must.  I was able to download v12.2.0.024 through the “SW update” application with no problem.  The interface was much more responsive after the update.  Initially it was super slow to respond to the change between portrait and landscape layout when rotated so the update is a must.  No doubt there are other important fixes but this seemed like the most visible to me.

After the update I grabbed the USB cable that came in the box and plugged it into my laptop (running Debian Lenny).  It “just worked”, detected without any issues and mounted it like a mass storage device.  From there copying songs was just drag and drop.

The amount of storage on this phone is huge: 32G built in.  So not only is the music player good, it can hold more than enough music.  I was kinda let down though when I realized that the music player doesn’t grab album cover art off the web.  This makes sense if you’re trying to minimize network traffic and since data plans are still super expensive it’s probably the right thing to do.  If you’ve got cover art saved in the directory with an album the player recognizes it no problem though so I guess this gripe is really just cosmetic.

So next was browsing the web.  The browser is pretty smooth and the flash player on it works great with YouTube.  No complaints here.  There’s even a feed reader that you can populate right from the browser.  Just pull up the menu on the right side of the browser, tap the icon that looks like three horizontal bars (the significance of which I still don’t get) then tap “Subsc. feeds” and you’re good.  The feed reader is simple enough but for whatever reason the menus don’t hide themselves like they do in the web browser.  This cuts out at least 1/4 of the screen real estate and for feeds with images this can make them pretty much unreadable till you open them up in the browser.

Eventually I got sick of waiting for the 3G connection to load pages with big graphics so I brought up the Wifi control panel.  Managing connections on this phone is a little awkward so if things don’t work right the first time and you have to go mess around with setting you’ll have a hard time finding the right place without hitting the manual.  Lucky you can get it off the Nokia site.

The Wifi connection is automatically set to be preferred over the 3G so my phone switched to the Wifi as soon as I activated it.  I tried to hit the web but it was super slow at first, then I started to get an error message: “Web: No Gateway Reply” … Very descriptive so I knew what to do right away … troll the interwebs for a few hours trying to find forum / mailing list post documenting a solution.

Seems like this error message basically describes any and all problems with a data connection on this phone.  I even found a page dedicated to trouble shooting this error but mostly their suggestions were focused on fixing bad configurations on home routers.  Eventually I started playing around with the configuration settings on the phone manually and got it to work.  I’ll post the work around tomorrow.  Maybe I’ll even figure out how to take screen shots.