Video encoding

Contents

Introduction

The N900 is a huge step up from the previous Internet Tablets when it comes to playing video files. It is capable of playing full 480p (854x480) files encoded with a variety of codecs, particuarly H.263 (MPEG4 Part 2/Xvid) and H.264 (MPEG4 Part 10). However, it still has some limitations which you need to be aware of to successfully transcode files to play back on the N900.

The native resolution of previous tablets is 800x480. Unfortunately, due to hardware limitations, tablets prior to the N900 cannot play videos at that native resolution. Because of this, most videos will need re-encoding for use on the tablets. This page aims to document those limitations and the tools available to convert videos to within those limits.

Quick Guide

Downloadable Presets

1. While Handbrake's 'Universal' and 'iPhone' profile will produce compatible files, it will do so at a lower quality level than the N900 supports, so its worth using settings more closely tailored to the device's capabilities.

- Handbrake Preset 1: N900 Optimized HandBrake Preset. (for Handbrake 0.9.4)

Step-by-step DVD to MP4 using Handbrake

Follow this step-by-step Handbrake (version 0.9.4) guide exactly as it is here to produce full original-resolution DVD encodes in H264 format playable at full speed with the built-in Media Player for the N900. There are no cropping or resolution changes necessary. Open the correct directory first using Source: DVD/VIDEO_TS folder. The resulting video file will be at the original DVD resolution (e.g., 720x304, 720x400, etc., . ).

- Necessary: (1) Container: MP4
- Necessary: (2) Web-Optimized selected (absolutely necessary!)
- Necessary: (3) Picture: 
                       (i) Frstly, select None for Anamorphic
                      (ii) Then, select Custom for Anamorphic (DON'T go editing the resolution!)
- Optional:  (4) Video Filters: 
                       (i) Decomb set to Default
- Optional:  (5) Video: Unchanged (default is H264/x264, Constant Quality 60.78%)
- Optional:  (6) Audio: Unchanged (as you like it)
- Optional:  (7) Subtitles: Unchanged (as you like it)
- Optional:  (8) Chapters: Unchanged
- Necessary: (9) Advanced:
                       (i) Reference Frames: 4
                      (ii) B-Frames: 0 (disables B-Frames)
                     (iii) CABAC Entropy Coding: unticked (switches this off)

Detailed Guide

The rest of this Wiki will explain in detail the various aspects to encoding on the N900 including converters, codecs and more

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.

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.

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.

The built in video player on the n8x0 devices should be used if videos were converted with this tool, versus mplayer.

Development of the official Nokia Internet Tablet Video Converter has ceased as of 25 March 2008.

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.

Media Converter

MediaConverter is a Java graphical application with several presets for transcoding video for the N800 or N770. Because it is a Java application it will run on many platforms, including Linux, Windows and Mac. You can select a batch of files, a preset encoding method and let it go. You can also have it produce 30 second samples for trying out different settings. Like tablet-encode it uses mencoder. On Windows, it comes with a setup.exe for easy install, and there are distributions for Linux and the Mac on the download page.

viDrop

viDrop is a free open-source GUI frontend for mencoder originally designed for Rockchip MP4 players but is able to encode to a variety of custom resolutions and bitrates. Supports batch processing, profiles and embedding subtitles, among other features.

Preferred Formats

There are three main aspects to the format of media files:

  • The Video Codec
  • The Audio Codec
  • The Container format

Video Codec

Two of the most popular codecs are H.263/XVid and H.264. Handbrake can produce files in both formats but it heavily emphasizes H.264. At a given file size, H.264 will result in better looking video, at a cost in increased encoding time. The cost is worth it, especially in the Handbrake context, where there is only a single basic Xvid profile and no tweaking allowed.

The Audio Codec

On the audio side, the two main supported choices are MP3 and AAC. AAC is better than MP3 at the same bitrate so you should always choose AAC. MP3 support is only useful for compatibility.

The Container format

Handbrake can only produce mkv and mp4 files and the tablets only supports mp4 out of the box. mkv files have additional features, but the tablet's media player doesn't support any of them, so lack of support is not a significant disadvantage at this time.

Subtitle Support

Subtitle support is one area where options are severely limited - the tablet's media player doesn't handle them. So, the only choice available is 'burned' subtitles - where Handbrake renders them into the video stream.

Extra codec support

Extra codecs for N900

The Decoders Support package adds support for some extra codecs and containers. Most particularly it adds support for mkv containers and ac3 audio tracks. As mentioned above, mkv container support isn't compelling. ac3 audio is interesting because most DVD audio tracks are encoded in ac3. This would allow you to copy the audio track without transcoding it. However, this is not necessarily ideal. Firstly, ac3 decoding will be done by the CPU, while AAC decoding is offloaded to a DSP which reduces power consumption. Secondly, you're not going to be able to take advantage of surround sound - meaning that storing a full 5.1 audio track wastes space.

You can also add Ogg Vorbis support to the N900 but that also suffers from lack of DSP acceleration.

Frame rates and hardware limitations

Limitations in the N900

The N900 essentially supports H.264's Baseline@3.0 profile. This particularly means that features like CABAC and B-Frames are not supported. These limits are reflected in the preset I provided. From a resolution point of view, it supports up to 854x480 and doesn't support 1280x720. The actual limit is unknown and in reality, it's inefficient to use even 854x480 because that's bigger than the screen.

On the audio side, there are no noticeable limitations. You will want to use AAC with a bitrate no more than 160kbit and 48KHz, which is what is used everywhere.

Limitations in previous tablets

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/N810 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.

Some recent tests have found that in some cases, higher resolutions can produce good results on the N800/N810. Specifically, 576x352 @ 24/25 fps or 480x288 @ 30 fps have been reported to work well if the bitrate is kept around 600 kbps.

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.


Anamorphic resolution support

DVDs are stored at a resolution of 720x480 but displayed at either 640x480 (for 4:3 video) or 854x480 (for 16:9 video). This means that video frames are stored 'anamorphically' - meaning that they are displayed at a different size from what they are stored at. Particularly, this means that the video frames have non-square pixels. Unfortunately, the media player doesn't understand this and will display the video at 720x480, resulting in squashed or stretched video. So, you must resize the video in Handbrake to ensure pixels are square.

Streaming video

The media player supports streaming video from http urls, but you must be aware of two things. First, in Handbrake you must ensure the 'Web Optimized' checkbox is ticked for mp4 files. This is already in my preset. Without it, you cannot stream the files. Secondly, the buffering algorithm is not designed to handle high bitrate files that would play normally from local storage. This means that you'll see a lot of pausing and buffering messages. It seems the highest bitrate it will stream happily is about 1MBit/s including audio. The preset is optimized for local storage - you can tweak it to produce smaller files if you need to stream.

Choosing a resolution

As mentioned above, you'll have to resize all DVDs you try to transcode, and maybe other files too. So it's good to know what target resolutions to use.

4:3 DVDs

4:3 DVD video is easy to handle. Just resize to 640x480.

16:9 DVDs

For 16:9 DVDs, it's harder. 854x480 is a valid choice, but the N900 will have to scale it down to display, so a better choice is 800x448 - which exactly fits on the N900 display. This means you are throwing away vertical detail and bloating the file horizontally but it's the least worst choice without anamorphic support.

Letter box DVDs

Occasionally, you'll see a DVD with widescreen content inside a 4:3 frame - so the black borders are in the actual video. To make the video display nicely, you'll need to use handbrake's crop feature to cut out the black bars. This is a pretty involved process because you're cropping the original anamorphic frame but need to store it with square pixels. So you might crop to 720x360 (16:9 inside 4:3) and then store it as 720x408 to get square pixels. For even wider movie content, you're vertical resolution will be even lower (272 and 306 respectively for 2.35:1 content)

SD sources

SD sources will generally have square pixels and 480p or less. You can keep the source resolution unchanged or if you have a true 854x480 source, shrink it to 800x448 as with DVDs.

HD sources

If you're scaling down an HD source, you'll want to target 800x448 as well. If the file is a movie that is wider than 16:9, the vertical resolution will be lower than 448 - just set the width to 800 and maintain the aspect ratio. Essentially all HD content has square pixels.

Alternative Media Players

You can, of course, use vlc or mplayer to play back files and all of these limitations will be removed. In exchange, you won't get any DSP accelerated video - which will eat battery life and introduce a new set of limitations based on CPU power.

Manual conversion instructions

Main article: Manual video encoding

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

See also