Video encoding

(Creating Streamable Video Yourself: Expanded the streaming video section, still needs a lot more entries.)
(Video converters: Added short intro)
Line 27: Line 27:
== Video converters ==
== 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 ===
=== Nokia Internet Tablet Video Converter ===

Revision as of 20:14, 9 June 2008

Image:Ambox_content.png
This is an article from the old midgard wiki that hasn't yet been fully updated for this wiki, please update it.
Please see the talk page for discussion.


The native display format of the Internet Tablets is 800x480 pixels. Full display area can be used in videoplayer by pressing the fullscreen button. When windowed, video is played at 600x360 pixels. Both give a 15:9 aspect ratio, not quite the 16:9 that is broadcasting standard, but close enough to look good.

Contents

Video Player limitations

The standard media player has some limitations due to the internal hardware:

  • it can only decode videos where horizontal and vertical dimensions are multiples of 16.
  • it cannot decode videos with high bitrates and/or high frame sizes. The limits are at about 800 kbps or 400x240 (352x288 on the Nokia 770).
  • it cannot decode both a high frame rate and a high frame size so if you want to keep the natural frame rate of your video (25 or 30 fps) you have to keep the frame size at 400x240 or less (288x160 on the Nokia 770).
  • audio must be at 44.1kHz or lower
  • external subtitles cannot be read so they have to be written inside the video frames
  • 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 add black bands when 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 how complex is the action.

As for the audio subsystem, mp3 at 128 kbps just works fine. 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.

Alternative video players

MPlayer for maemo can be used to overcome a lot of the default player's limitations, and is highly recommended to all users as it will provide a significantly better viewing experience than the built-in Media player on almost all formats, and supports external subtitles.

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 app for N800 and N810 devices. It's current available for Windows XP and Vista, and Mac OS X.

The app is designed to be a simple drag/drop bulk converter of videos. While it doesn't have the bells and whistles of some of the other apps, it's meant 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.

Media Converter

Media Converter eases the process of converting videos to maemo mpeg4 format. It also supports two-pass coding that produces better quality videos. Screenshot's quite old. New one much better. Supports dragn drop of files.

Note: Sun Java 1.4 or later needed. Linux version needs mencoder installed.

tablet-encode

To generate video which will play correctly on Nokia tablets, the easiest method is to use tablet-encode, which wraps mencoder from MPlayer. The program offers a number of predetermined sets of options to optimise image quality, framerate and size.

MediaCoder

Media Coder can be used to directly convert VOBs (DVD files) into AVI's and provides several encoder to convert them into playable formats for mplayer. It is a great software for video editing and format conversion. The best thing about this is that it allows the end-users to select the audio tracks for the video to be encoded, unlike Kontori Media Converter which use the default audio track . You can also do many other things like set different screen sizes and bit rates. It works for all devices as well. Nokia N800 Video Convert

Very easy to install and use, great results. Uses the MEncoder engine.

Handbrake

HandBrake is a GPL'd multiplatform, multithreaded DVD to MPEG-4 ripper/converter. HandBrake was originally available on the BeOS, but now has been ported over to MacOS X and to GNU/Linux.

Handbrake will allow a direct rip from a device to the format that will play on the 770. This first screenshot shows example settings (based on information found in this wiki) that are known to work. In order to change the size, you must click on the "Picture settings..." button at the bottom. This will bring up the a dialog box, where you'll need to specify the size (288x160 is what I used).

Tested on Mac OS X

SUPER

"SUPER © Simplified Universal Player Encoder & Renderer.....SUPER © plays & encodes very fast full length movies to any other format without any time or function limitation."

Essentially it's an all-in-one GUI to different encoding back-ends with a simple, one-click interface (though simple belies to potential of this system). It's completely free, windows only AFAIK.

Streaming video

There are a lot of packages available to provide on-demand on-the-fly streaming video to the NITs. These packages provide you access to media located on a server by transcoding the media to fit within the limits of the device. Unfortunately, do 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 modest quality reduction.

mediaserv

mediaserv is part of the mediautils suite by Andrew Flegg. 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 is better suited to Linux or Mac OS X than Windows, but offers plenty of customization and is very simple to 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 cable/satellite/dvr box, reencoding and streaming it to your NIT. It's a non-free hardware-based solution, but fans of the Slingbox approach may appreciate it.

HelixProducer

As maemo supports Real Video streams, you can use HelixProducer to create them from your own inputs.

Manual conversion instructions

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.