Monday, July 26, 2010

Video Formats Supported by Nokia 5310 Phone

Yes, I know it is silly...watching videos on a Nokia 5310 is far from optimal since it has such a small screen.  However, if you ever find yourself in situations where you want to watch some videos to kill some time, the information below will help you get playable videos/movies on your phone.  This article lists the video formats supported by the phone and provides Handbrake presets that will allow you to transcode movies for your phone.

Supported Video Formats (Nokia 5310 XpressMusic)
Here are the video formats supported by the phone (I gathered the initial info from this link):
  • 3GPP formats (H.263)
  • H.264/AVC
  • MPEG-4
Even though the Nokia 5310 has a screen resolution of 320x240 (in landscape), the max video resolution supported by the phone is:
  • 176x144.  I have run some tests and this is indeed the max resolution, but I have found that 176x128 resolution videos provide the proper ratio to fill the screen when watching videos in fullscreen mode on the device (where you turn the phone sideways into landscape mode).  At first I tried to encode movies in anamorphic 176x144 modes to retain as much detail as possible, but the phone doesn't handle anamorphic video properly.  Since anamorphic video isn't supported, the video has to be stored with a 1:1 pixel ratio, and I found that 176x128 was the best resolution to use.  If you try to encode movies beyond these resolutions, you will hear audio but you won't see any video playing.
Handbrake Presets
Handbrake is an application that can convert/transcode your DVDs into smaller/alternate video formats.  I have saved several presets from this application that can be used to encode video for a Nokia 5310.  In this case, I was using the Linux version of Handbrake (Handbrake-GTK).  I would assume the presets I have saved can be imported into the Windows version of the software as well, but I haven't tested it.  You can download my saved presets from: here.  You will see the following presets in a 'Nokia 5310' folder after importing them into Handbrake:
  • Low (100kbps mpeg-4) - This preset renders watchable, but somewhat blocky video.  You probably only want to use this preset if you need the smallest video size possible.
  • Medium (200kbps mpeg-4) - This preset will still exhibit some blockiness, but it is a good compromise if you don't want to use the highest setting.
  • High, 15fps (100kbps h.264) - This preset uses h.264 video, which produces the best looking video, but it will only be at 15fps. I tried to encode h.264 videos at higher framerates, but they looked choppier than those encoded at 15fps...probably because the phone couldn't keep up with h.264 at higher framerates.
  • High (300kbps mpeg-4) - From my tests, 300kbps mpeg-4 video provides the best balance of smoothness (fps) and video quality but at the expense of storage space.  An mpeg-4 file at this bitrate looks almost as good as the h.264 preset but will take up about 1.8x more storage space (around 300MB for your average movie).
All of the presets use mpeg-4 video except 'High, 15fps' which is configured for h.264 video instead. All of the presets are configured for AAC 128kbps stereo audio.  I tried mp3 instead of aac, but the audio didn't play on the Nokia 5310 when using that format (this could just be an issue with how Handbrake adds mp3 audio to .mp4 files or a bug on the phone...who knows).

After selecting any of these presets in Handbrake, you may want to modify some other settings before starting a transcode job.  You may want to enable 2-pass encoding and you will most likely want to change the crop settings so the resulting video fills the phone's screen:
  • 2-pass encoding - On the 'Video' tab in Handbrake, just check the 2-pass encoding box if you want to enable this option. It should produce better video overall than the standard 1-pass encoding.
  • Crop Settings - If the movie you are transcoding is in a widescreen format (e.g. 16:9), you will most likely want to crop the video so it will fit the phone's screen (4:3 format).  As mentioned earlier, cropping the file so it ends up at 176x128 (4:3 format) is the optimal resolution for this phone's display and decoding capabilities.
The picture below shows an example of the crop and storage settings that are available in the Linux version of Handbrake.  These settings can be seen when you click on Picture Settings.
When modifying the crop settings, you need to uncheck the Auto Crop and Loose Crop boxes as seen above.  Next, Change the left and right side crop settings until the the Storage column shows a width of 176 and height of 128 (in this case, 100 pixels were chopped off each side of the movie to force it into a 4:3 format).  You will probably need to keep resetting the width back down to 176 after modifying the crop settings because the numbers can change automatically when the other fields are modified. Also, make sure that Anamorphic is Off and Alignment is 16.  I tried smaller alignment settings but the Nokia phone didn't handle them too well...16 is standard (I believe all this means is that the width and height values need to be multiples of 16).

One of the only things left to mention is that after you have copied a movie over to the phone, make sure you let the phone update the media library before trying to play a video, otherwise videos will play back a little choppy.  To initiate the process, open up the music player on the phone after copying the files over and it will automatically start updating the library (showing the status as it progresses).  If you don't manually start this process after transferring movies to the phone, the library update process will still run but it will run in the background without reporting progress.  The advantage to manually initiating the update process is that you can see when it is finished, so you know when you can start playing videos without them being choppy.

NOTE: Just as a side note. I inserted a 16GB microSD card in the phone and the memory status screen reported the correct size, used space, and free space on the card.  Even though the manual for this phone says it only supports up to 4GB, I believe some of the larger SDHC cards should work. I didn't have a chance to test the 16GB card over a longer period of time, though, so I'm not sure if using a card of this size will negatively impact the phone's operation in any way.  At any rate, a 16GB card would work well for sticking a bunch of videos on the phone.

Sunday, July 25, 2010

Nokia 5310 SIM Unlock Instructions

I recently unlocked my Nokia 5310 XpressMusic phone that I am using with T-Mobile and thought I would post some instructions for the unlock process.  If you have been on a contract with T-Mobile for a certain amount of time (at least 3 months I think but it could vary based on phone), you can call T-Mobile and get an unlock code emailed to you within 1 to 7 days.  It took less than a day for me.

I received an unlock code and the following instructions from T-Mobile:
NOTE: If you receive an error message while performing the instructions below, stop. Please be aware that if an excessive amount of incorrect attempts are made, the phone will be permanently locked.

1.  Press #
2.  Press * three times = P
3.  Press * four times = W
4.  Press * twice = +
5.  Enter the unlock code
6.  Press * twice = +
7.  Press 1, then # and the display should read "SIM Restriction Off"

Pay special attention to the note above about your phone getting permanently locked if too many incorrect attempts are made to unlock the phone.

Friday, July 23, 2010

DVD Backups Using Linux

A couple of weeks ago, I finally got around to backing up some of my personal DVDs.  There are several methods that exist for accomplishing this task under Linux, so I'll list some of the common tools that are out there and then explain why I chose the tools I did.

In order to backup DVDs, here are three approaches you could take:
  • ISO - ISO image backups allow you to create archival quality backups of your DVDs by creating a copy of the DVD image on your computer.  This gives you the advantage of having the original video streams, audio streams, and DVD menus at the expense of increased storage requirements (between 4-8GB per DVD). Several applications support DVD playback and/or transcoding from ISO images: MythTV, VLC, Handbrake, K9Copy, etc.

    Examples of ISO backup software:
    dvdbackup/genisoimage (CLI) - The combination of these two command line tools is very useful for backing up DVDs.
    K9Copy (GUI) - I was reluctant at first to try this since it requires QT libraries to be installed on Ubuntu, but I'm glad I did.  It was the best GUI tool I found for creating ISO images of DVDs.
    Gnome (GUI) - Right-click on a disc's icon on the desktop, then select Copy Disc.... This works for some DVDs, but it won't work for everything.

  • Transcode - Transcoding involves converting the original video and audio streams on a DVD to another format (h.264, Ogg Theora, etc).  This has the advantage of shrinking your video down to 1 to 2 GB while still maintaining good quality video (although usually not as good as the original video).  These smaller video sizes are possible because newer video encoding schemes can compress video much better than MPEG-2 video which is the standard for DVDs.  Transcoding saves disk space but can take a long time if you have a slower computer.

    Examples of DVD transcoding software:
    Handbrake (GTK or CLI version) - Transcoding DVDs is its only job and it does it very well.
    K9Copy (GUI) - Equivalent to DVD Shrink on Windows.
    dvd::rip (GUI)
    mplayer/mencoder (CLI)
    Others - Thoggen, VLC, AcidRip, ogmrip

  • Requantizer - This method (think DVD Shrink or K9Copy in shrink/copy mode) can extract the mpeg-2 video stream, run it through a requantizer which degrades quality, and finally re-packs the video data into the stream again.  This method is quite fast and is usually used to shrink a dual layer DVD (approximately 9 GB) down to single layer size (approximately 4.7 GB).

    Examples of requantizer software:
    K9Copy (GUI)
    vamps (CLI) - low-level command line tool...not capable of making DVD backups on its own
This isn't meant to be an exhaustive list of solutions for backing up DVDs, but it should get you started in the right direction.  Experiment and choose the method/software that best suits your needs.

ISO Image Backup Instructions

I wanted a solution that preserved the original quality of the video and audio, so I went the route of creating ISO images of my DVDs.  One advantage to this method is that it still allows you to easily transcode to other formats later (for use on smartphones and other embedded devices) since software like Handbrake and K9Copy can read and transcode from ISO images as well as regular DVD discs.  Handbrake would be particularly well suited for transcoding from the ISO images at a later date because it allows you to queue multiple jobs.  Queuing jobs gives Handbrake the ability to transcode multiple DVD ISO's or your entire collection at once (one after the other) without having to transcode each DVD individually.  You might be waiting a long time if you have a lot of DVDs but at least it streamlines the process and minimizes the amount of interaction required on your part.

I chose to use the dvdbackup and genisoimage command line utilities since it was one of the simplest methods, plus it allowed me to automate the process in a bash script.  The first step is to use 'dvdbackup' to extract the video and menu files files from the DVD:

$ dvdbackup -M -v -r b -n dvdname

Replace dvdname with the volume label of the DVD disc (i.e. the name of the Movie).  You can leave off the '-n dvdname' option if you want because it can be automatically read from the DVD disc in most cases.  The '-M' option tells dvdbackup to mirror the entire disc. Refer to the dvdbackup man page for the other options that are used.

Next, use the files that were just extracted from the DVD to create an ISO image of the DVD:

$ genisoimage -dvd-video -udf -V dvdname -o dvdname.iso dvdname/

Again, replace each instance of dvdname in the command above with the volume label that you want stored in the ISO image that will be created.  This volume label should be a max of 32 characters, is normally all uppercase, and usually uses underscores instead of spaces.  The options used with genisoimage are explained below:
  • -dvd-video - generates a DVD video compliant filesystem
  • -udf - include UDF filesystem support
  • -V dvdname - applies the appropriate volume label to the ISO image so that when you play the ISO image in VLC or other software it will show the name of the movie
  • -o dvdname.iso - specify the output file for the image
  • dvdname/ - the directory containing the dvd files that were extracted with dvdbackup
That's it...two commands and you should have your DVD backed up.  I should note that there doesn't seem to be one method out there that works with every single disc, so be willing to use other software like K9Copy if this doesn't work.

Hardware Monitoring With the Gnome Sensors Applet

The Gnome sensors applet allows you to monitor hardware sensors (fan speeds, temperatures, voltages) in the gnome panel as shown below, but it is not installed by default in Ubuntu.

Install it with the following command:

$ sudo apt-get install sensors-applet

Now that it is installed, add it to the gnome panel by:
Right clicking on the Gnome panel (an empty area) > Add to Panel... > then add the Hardware Sensors Monitor applet.

After it is added to the panel you can open up the preferences dialog (right click the sensors on the gnome panel > preferences) and choose which sensors are displayed.  The screenshot below shows the sensors that were detected by default on my system.  For each sensor, you can dive into its properties and optionally set alarms for high and low threshold values if desired.

Thursday, July 22, 2010

Hiding Those Pesky Gnome Panels

I periodically run into the problem where applications in Gnome don't go into fullscreen mode properly. The top and bottom Gnome panels remain displayed on top of everything else as in the screenshot below. This post shows how to work around this problem by modifying some compiz settings.

This seems to be a common problem with MythTV, OpenOffice Impress, and other applications that have fullscreen modes.  The fix is simple.  Install the compizconfig-settings-manager package onto your system.  On Ubuntu, the command to install it is:

$ sudo apt-get install compizconfig-settings-manager

After the installation finishes, you will have a new application, CompizConfig Settings Manager, listed under: Gnome System menu > Preferences.

Open it and start typing 'workarounds' in the Filter search bar.  Select the Workarounds plugin and enable the Legacy Fullscreen Support option as shown in the screenshot below.

Now, the next time you open MythTV or another fullscreen application you won't get the Gnome panels showing on top of everything else.