Nokia N770/N800 Video Playback

From GrinningMonkey

Contents

Video on the N770 and N800

The Nokia Internet Tablet (NIT from now on, TLA FTW) is awesome for many reasons, one of them being that you can carry a whole lot of video around in your pocket.

I just got a 2GB memory chip for my N770 and started playing around with video encoding yesterday evening. While waiting in the car for my fiancee to show up, I watched half an episode of Gargoyles, taking away the boredom of a 10 minute wait. Lesson learned: waiting rooms, long car trips (only as a passenger, of course), keeping your kids occupied, working out on an exercise machine - lots of scenarios for handy pocket-video watching.

The purpose of this page is for me to document and share what I've learned about transcoding video for playback on the NIT. I will be receiving my N800 someday soon - my fiancee has all but commandeered my N770 for playing games, taking notes, etc. but that's another story - and when I get it I'll add some updates here.


Encoding tools

I'm using mencoder (part of MPlayer, the popular linux media player, very good at transcoding) and tablet-encode (perl script from http://mediautils.garage.maemo.org/tablet-encode.html). tablet-encode calculates some parameters and then calls mencoder. I've modified the settings to try out different bitrates and resolutions to find different settings that trade quality for size and still work well on the 770.

I imagine that any encoding tool will work as long as the right file format (indexed AVI) and resolutions (see below) are used. I imagine that you needn't use this particular toolchain to find my research here useful.

Encoding note: I found that the file must be indexed for the built-in player to work. I don't know whether MPlayer will play non-indexed files, because once I found it costs almost nothing to add it, I didn't care to try it without.


Playback

I compared the built-in video player to MPlayer for Maemo on the N770:

Observations

  • The built-in player does not want to play videos at 400x240. It did not want to play one I encoded at 352x either. It played 320x ones
  • For the 320x ones, the built-in player looked better than the same file played in MPlayer (something that looked like jaggies showed up in MPlayer)
  • For higher-bitrate 320x files, the built-in player started skipping frames. MPlayer didn't
  • MPlayer handled 400x files just fine. I haven't been able to find a bitrate that MPlayer drops frames on yet (It does conk out on 800x files, but at least it tries)

Conclusions

  • I think the built-in player is interpolating in software. I think MPlayer is giving the 320x feed to the hardware which is doing a poor(er) job of interpolating
  • MPlayer is the way to go on the N770, unless I've got low res. files


Hardware and resolutions

My understanding from the MPlayer for Maemo homepage is that the N770 video hardware can do double-pixel scaling natively but cannot handle arbitrary scaling/interpolation. The N800 video hardware supposedly can.

Be that as it may, the screen's native resolution for both the N770 and N800 is 800x480. I note that bitrate has much more effect on quality than resolution. If I'm going to be re-encoding anyways, I might as well choose something that will look good and work well on both platforms.

See the note on the MPlayer page (above) about which resolutions best map to which aspect ratios.


Tests

This part is more subjective than I would like. Ideally I would have a nice, big matrix of different bitrates, resolutions and other things to try out. Given all the possible variables and the time it takes to do encoding, and my impatience at finding some settings that work well for me, I narrowed it down.

The goal of these tests is (1) to discover how bitrates and resolutions and different videos affect size, and (2) to come up with some combinations of quality and size that produce output acceptable to me.

I've come up with the following pre-sets:

Preset name ABR (kB/s) VBR (kB/s) VRES (w x h) FPS
customlq 96 96 400x240 15
customm1 112 160 400x240 15
customm2 112 256 400x240 30
customh1 128 320 400x240 15
customh2 128 320 400x240 30
customh3 128 512 400x240 30
customh4 128 512 800x480 30

I had a duplicate set with an "s" prefix ("scustom") where the resolution was 320x240, intended for standard 4:3 resolution. However I discovered that when using the -o Maintain original aspect ratio in tablet-encode it correctly picks an appropriate resolution - at least, it did for Friends (1.33:1 from DVD), Office Space (1.85:1 from DVD), X-Men III (2.40:1 from DVD) and Gargoyles (512x384 from a downloaded collection*) - so I won't list that set of presets.

I encoded the first 20min. of each show with each preset, to get a feel for the size. Here are the results. Each entry lists four numbers:

  • MB/20m (the original file size)
  • MB/min
  • MB/hr
  • hr/2GB (how many hours would fit on a 2GB memory chip in an N770)
Video/orig.res/enc.res lq m1 m2 h1 h2 h3 h4
OfficeSpace/1.85:1/400x224 30.63 1.53 91.88 21.77 42.56 2.13 127.69 15.66 49.71 2.49 149.13 13.41 68.66 3.43 205.99 9.71 59.74 2.99 179.22 11.16 82.56 4.13 247.67 8.08 82.89 4.14 248.68 8.04
FriendsS1E1/???/320x240 30.58 1.53 91.74 21.80 42.55 2.13 127.66 15.67 57.40 2.87 172.21 11.61 68.89 3.44 206.68 9.68 69.38 3.47 208.14 9.61 98.14 4.91 294.41 6.79 98.21 4.91 294.62 6.79
XMen3/2.40:1/400x224 30.38 1.52 91.14 21.95 42.28 2.11 126.85 15.77 49.46 2.47 148.37 13.48 67.97 3.40 203.92 9.81 59.45 2.97 178.35 11.21 81.99 4.10 245.98 8.13 82.56 4.13 247.68 8.07
Gargoyles101/512x384/320x240 24.77 1.24 74.30 26.92 34.29 1.71 102.88 19.44 49.16 2.46 147.47 13.56 39.96 2.00 119.87 16.68 58.70 2.93 176.09 11.36 69.97 3.50 209.92 9.53 87.59 4.38 262.76 7.61

Power

I watched Office Space in its entirety (89min) after fully charging my N770. When the show was done, the battery meter showed full. After power cycling the NIT, the power meter showed full less one bar.

Conclusion: I'm certain it's good for at least one full-length movie, maybe even an extended-length one like Lord of the Rings. Beyond that I have to test further.


Two-pass encoding

Using variable bit rate allows the encoder to drop the bit rate when it is not needed so much (low-movement scenes) so that it can use a higher bit rate in other places (high-movement action type scenes) while still maintaining the overall bit rate we told it to.

In single-pass mode the encoder is often forced to use a lower bit rate in those action-type scenes than it otherwise could have, since it has to maintain the overall average you specified and it only knows about the video it's encoded so far but knows nothing about the future video it still has to encode.

In 2-pass mode, the encoder goes over the video and makes notes about the whole thing. Then it can use a greater variance in bit rate.

From http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-dvd-mpeg4.html:

In simple modes such as CBR, however, the encoders do not know the bitrate needs of future scenes and so cannot exceed the requested average bitrate for long stretches of time. More advanced modes, such as multipass encode, can take into account the statistics from previous passes; this fixes the problem mentioned above.

With a two pass encode, the first pass will rip the movie as though it were CBR, but it will keep a log of properties for each frame. This data is then used during the second pass in order to make intelligent decisions about which quantizers to use. During fast action or high detail scenes, higher quantizers will likely be used, and during slow moving or low detail scenes, lower quantizers will be used. Normally, the amount of motion is much more important than the amount of detail.


I tried this twice, with the first episode of Gargoyles and the first 20m of Office Space:

  • I didn't notice much difference between the 1p and the 2p versions
  • The sizes were almost exactly the same (expected)
  • The 2p version actually looked a little worse to me (I played both versions on my PC in double-size mode to look at artifacts).


Conclusion

I have no conclusions yet, only a sneaking suspicion that the encoder is trading too much quality in low-movement scenes for my taste. I guess, for something like the N770, I look for quality more in the slow parts and am more willing to accept blocky video in high-action parts. The encoder thinks that quality during motion-rich scenes is more important than detail in slower bits and that's not necessarily true for my tastes.

I believe further tests are in order but I am leaning towards single-pass.

Conclusions

NOTE: These are subjective based on my own judgment of quality.

  • 30fps is much more enjoyable than 15fps and the hardware is more than capable of it.
  • The difference between M2 and H2 quality-wise is noticeable, but barely.
    • Since I'm a quality nut, I will use H2 for most of my encoding, at least for the first little while while I'm excited about building videos for the NIT
    • ... but I could easily be swayed to use M2, and probably would if it meant the difference between carrying around a full set of shows or not.
  • With 8GB of storage in the N800 (roughly 40 hours of video at H2) that's more than enough for a season of ANY show

Settings

Edit tablet-encode, find the hash of settings and add this:

    customlq => { abitrate => 96, vbitrate => 96, width => 400, height => 240 },
    customm1 => { abitrate => 112, vbitrate => 160, width => 400, height => 240 },
    customm2 => { abitrate => 112, vbitrate => 256, width => 400, height => 240, fps => 30 },
    customh1 => { abitrate => 128, vbitrate => 320, width => 400, height => 240 },
    customh2 => { abitrate => 128, vbitrate => 320, width => 400, height => 240, fps => 30 },
    customh3 => { abitrate => 128, vbitrate => 512, width => 400, height => 240, fps => 30 },
    customh4 => { abitrate => 128, vbitrate => 512, width => 800, height => 480, fps => 30 },

... and to invoke:

tablet-encode -pcustomm2 -i -o dvd://1 OfficeSpace.avi