Video encoding

The native resolution of the tablets is 800x480, unfortunately (due to hardware limitations), playback of videos at that resolution is not possible. Because of this, most videos will need reencoding for use on the tablets. This page aims to document those limitations and the tools available to convert videos to within those limits.

Media player limitations
The standard media player has some limitations:


 * Horizontal and vertical dimensions must be multiples of 16.
 * Video data rate and resolution is limited to about 800Kbps and 400x240 (352x288 on the 770).
 * Audio must be at 44.1kHz or lower (performance drops dramatically with 48KHz audio).
 * It does not support external subtitles, so they must be hardcoded.
 * DivXs need a FOURCC of "DIVX" rather than "DX50".

To encode video that will scale nicely to the screen aspect ratio, you can use either 240x144 (slightly larger than QCIF), 352x208 (slightly smaller than CIF) or 400x240 (N800 only). Of course if your source video is in a 4:3 aspect ratio, then you should stick with CIF (352x288) or QCIF (176x144). The video player will letterbox or pillar box as needed.

The demo video that comes with the N800 is encoded at 600kbps, with a frame rate of 30fps and a resolution of 400x240. To calculate the pixels per second, the equation is 400x240x30 = 2.88 Megapixels/second.

For the Nokia 770, 1.52 Megapixels/second is achievable, but again, this depends on the complexity of the action.

As for the audio subsystem, MP3 at 128Kbps works well. You can reduce the bitrate if you want to limit the file size and if you plan to play the file with the internal speaker only.

MPlayer
MPlayer for Maemo is not as limited as the built-in Media player, and recommended over the built-in player for all users. More video codecs are supported, higher video bitrates and resolutions will play without framedrop, and external subtitles are supported.

Video converters
These converters provide fairly simply interfaces to easily convert video to a NIT-friendly format for those who don't want to invest a lot of time or need a lot of customization options.

Nokia Internet Tablet Video Converter
Internet Tablet Video Converter is the official Nokia video conversion application for N800 and N810 devices, available for Mac OS X and Windows.

The application is designed to be a simple drag-n-drop bulk converter of videos, with minimal configuration option to be simple and fast to use. In addition, it provides a developer API for hooking into the conversion process so that 3rd party developers can modify what gets converted and how.

tablet-encode
tablet-encode is a mencoder wrapper that offers a number of presets designed for the tablets. Additional presets can be set by the user for greater quality, as the default set is generally optimized for streaming.

Handbrake
HandBrake is a free and open source multiplatform, multithreaded DVD to MPEG-4 converter, available for Linux, Mac OS X, and Windows.

HandBrake is intended primarily to convert VOB files from DVDs.

Streaming video
There are a lot of packages available to provide on-demand on-the-fly streaming video to the tablets. These packages provide you access to media located on a server by transcoding the media to comply with the limits of the device. Unfortunately, due to the overhead imposed by the network transfer, streaming video is necessarily of lower quality than video played back locally on the device, but the advantages of on-demand access to your entire media library may out-weigh the slight reduction in quality.

mediaserv
mediaserv is part of the mediautils suite by Jaffa. It provides a web-interface to your media and streams that media to you using tablet-encode and mencoder. It can be somewhat difficult for users unfamiliar with the command line to set up and use. Will work well with either Linux or Mac OS X.

Orb
Orb is a transcoding and streaming media server for Windows. It is easy to set up and use.

HAVA Player
HAVA is a Slingbox-like device that has a software player for the N800 and N810. It works by connection to your set-top-box, reencoding and streaming it to your tablet. It's a non-free hardware-based solution, but fans of the Slingbox approach may appreciate it.

Manual conversion instructions
These tools offer manual conversion for those who need lots of customization options or just like getting down to the nitty-gritty.

Mencoder
The tool I use to encode video is mencoder that comes with mplayer on Linux. Always start with the cleanest video you can, and make sure it has good A/V sync before you start by watching it on a PC. Make sure the original has a frame rate greater than or equal to the one you are trying to generate.

The recommended way to run mencoder is through tablet-encoder. You can however try running mencoder directly and playing with the options. Be careful about forcing the output frame rate, however. I didn't get any good result with the below commands. Instead, I got A/V desync and bad effects due do frame rate changes, so I now use some variation of the above shell scripts.

mencoder infile.avi -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4 -vf scale=352:208 -ffourcc DIVX -ofps 15 -o outfile.avi

This will generate a 15fps 352x208 avi file.

The following mencoder command line will make smaller videos:

mencoder infile.avi -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4:mbd=1:vbitrate=300 -vf scale=352:208 -ffourcc DIVX -ofps 15 -o outfile.avi

To make even smaller, you can drop down the quality of audio to 64 kbit/s (for 300 kbit video stream, converting audio to 64 kbit versus 128 kbit yields a total save of approx 20%. Notice that for lower bitrate movies percentage is considerably higher):

mencoder infile.avi -oac mp3lame -lameopts abr:br=64 -ovc lavc -lavcopts vcodec=mpeg4:mbd=1:vbitrate=300 -vf scale=352:208 -ffourcc DIVX -ofps 15 -o outfile.avi

The differences are the block detection method (mbd=1) and a capped bitrate see man mencoder for more options

ffmpeg
It is possible to transcode a video with ffmpeg. But the video will have a corrupted fourcc header. This can be corrected with the tool avifix from transcode or by using -vtag DIVX in ffmpeg command line:

ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -s 176:144 -b 200 -pass 1 outfile.avi ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -s 176:144 -b 200 -pass 2 outfile.avi avifix -i outfile.avi -F "divx"

Or directly (without avifix):

ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -vtag DIVX -s 176:144 -b 200 -pass 1 outfile.avi ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -vtag DIVX -s 176:144 -b 200 -pass 2 outfile.avi

transcode
I just converted a DVD using transcode using the following command line:

transcode -i /dev/dvd \ - x dvd \ - T 1,1-16 \ - a 0 - j 48,0,48,0 \ - Z 240x160 \ - y xvid \ - V -w 300 \ - N 0x55 \ - b 48 \ - o output.avi

This transcodes chapters 1 to 16 of title 1. The DVD has 720x576, but uses only 720x480, so I clipped off the remaining 96 black pixels with the -j option. Output size is 240x160. Video bitrate is 300kbps, audio is 48kbps. The "xvid" codec (a symlink to xvid2 on my system) gives very good results with the default settings. Do not use "mpeg4", it needs too much processor power for decoding which causes loads of artefacts when playing on the Nokia, even if it looks good on a PC.

I used the transcode package with Debian unstable.

afterwards, I fixed the FOURCC with

avifix -i output.avi -F DIVX

The resulting AVI file has 114 MByte for 45 minutes/25fps. Things can certainly be improved by tuning xvid options using a ./xvid2.cfg, but I didn't try that yet.

Here is another example, where the DVD has 720x576 fully used for 4:3 content. I chose 256x192 as output size (4x64, 3x64). This time I used the xvid4 codec. Note that you must not use B-frames, the 770/N800 doesn't seem to be able to handle them. You can turn them off by setting max_bframes=0 in your xvid4.cfg, you can easily do this with the xvid4conf tool. After you did this, the following command line will do the rest:

transcode -i /dev/dvd \ - x dvd \ - T 1,-1 \ - a 0 - Z 256x192 \ - y xvid4 \ - V -w 300 \ - N 0x55 \ - b 48 \ - o output.avi

The -T 1,-1 option will convert the whole title 1 (all chapters). You can try a lower video bitrate by adjusting the -w parameter (300kbps in this example). Don't forget to fix the FOURCC with the avifix command (as above)! The quality is very good, and it works fine with 25fps.

Additional informations regarding transcode and IT 2006 beta :

I suggest using the following command-line :

transcode -i /dev/dvd \ - x dvd \ - T 1,-1 \ - a 0 - Z 352x208 \ - -keep_asr \ - y ffmpeg \ - F mpeg4 \ - w 300 \ - N 0x55 \ - b 48 \ - R 1 \ - o output.avi

and transcode -i /dev/dvd \ - x dvd \ - T 1,-1 \ - a 0 - Z 352x208 \ - -keep_asr \ - y ffmpeg \ - F mpeg4 \ - w 300 \ - N 0x55 \ - b 48 \ - R 2 \ - o output.avi

using ffmpeg, there is no need to fix FOURCC. -R x is used to do two-pass encoding. --keep_asr will resize source video to fit in the specified target resolution, no need to worry about cropping or adding black borders if source isn't using the same aspect ratio (DVD often uses 1.77 anamorphic format ), transcode will take care of it. The only choice to do is target resolution : 320x208 or 240x144 for 16:9 source, 352x288 or 176x144 for 4:3 source.