Video encoding

(Encoding Software)
 
(111 intermediate revisions not shown)
Line 1: Line 1:
 +
== Introduction ==
 +
The [[Nokia N900|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 pixels) 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.
-
{{Midgard wiki}}
+
The native resolution of previous tablets is 800x480 pixels. 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.
-
== General Information ==
+
== Encoding Software ==
 +
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.
-
The native display format of maemo 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.
+
=== Handbrake ===
 +
{{main|Ripping DVDs with Handbrake}}
-
== Video Player limitations ==
+
[http://www.handbrake.fr 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.
-
The standard media player has some limitations due to the internal hardware:
+
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 it is worth using settings more closely tailored to the device's capabilities.
-
* it can only decode videos where horizontal and vertical dimensions are multiples of 16.
+
* Handbrake Preset 1: [http://intr.overt.org/misc/Baseline@3.0.plist N900 Optimized HandBrake Preset]. (for Handbrake 0.9.4)<br>
-
* 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). However, mplayer is able to play files of higher resolution, although frame rate will drop where the bitrate becomes high (during high motion scenes, for example).
+
{{ambox
-
* 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).
+
|type=notice
-
* audio must be at 44.1kHz or lower
+
|text=Note for more recent builds of Handbrake you must disable "Weighted P-frames" or the output will be Main Profile.}}
-
* external subtitles cannot be read so they have to be written inside the video frames
+
* Handbrake Preset 2: [http://dl.dropbox.com/u/9311656/N900.plist N900 Fast x264 800x480]
-
* 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.
+
=== Arista ===
 +
[http://www.transcoder.org/ Arista] is a video conveter supporting out-of-the-box N900. It works basing on presets, among which are presets for N900. No need to download anything more.
-
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.
+
It's only known to support Linux. But, because it is written in PyGTK, it may be set up to run on Windows & MacOSX as well.
-
For the Nokia 770, 1.52 Megapixels/second is achievable, but again, this depends on how complex is the action.
+
=== tablet-encode ===
-
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.
+
[http://mediautils.garage.maemo.org/tablet-encode.html tablet-encode] is a [http://www.mplayerhq.hu/ 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.
-
== Alternative video players ==
+
=== Media Converter ===
-
[http://mplayer.garage.maemo.org/ MPlayer for maemo] can be used to overcome some of the default player limitations and play full framerate video. Also it supports external subtitles.
+
[http://garage.maemo.org/projects/mediaconverter/ MediaConverter] is a Java graphical application with several presets for transcoding video for the [[Nokia N800|N800]] or [[Nokia 770|770]]. 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|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 [http://garage.maemo.org/frs/?group_id=26 download page.]
-
== Video converters ==
+
=== viDrop ===
 +
 
 +
[http://vidrop.learnfree.eu/ viDrop] is a free and 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. It works on Linux and Windows, and supports batch processing, profiles and embedding subtitles, among other features.
=== Nokia Internet Tablet Video Converter ===
=== Nokia Internet Tablet Video Converter ===
-
This is the official Nokia video conversion app for N800 and N810 devices. It's currently available for Windows XP only, but versions for Windows Vista and OS X will be available in the future.
+
{{main|ITVC architecture}}
-
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.
+
[http://www.nokia.com/A4688059 Internet Tablet Video Converter] is the official Nokia video conversion application for N800 and N810 devices, available for [http://nds1.nokia.com/NOKIA_COM_1/Microsites/BetaLabs/applications/apps/Internet_Tablet_Video_Converter-0.32.pkg.zip Mac OS X] and [http://nds1.nokia.com/NOKIA_COM_1/Microsites/BetaLabs/applications/apps/Internet_Tablet_Video_Converter-0.32.exe Windows].
-
* Main download site:
+
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 [http://maemo.org/community/wiki/internettabletvideoconverter/ developer API] for hooking into the conversion process so that 3rd party developers can modify what gets converted and how.
-
* Developer API documentation:
+
-
=== Media Converter ===
+
The built in video player on the N8x0 devices should be used if videos were converted with this tool, versus mplayer.
-
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.
+
Development of the official Nokia Internet Tablet Video Converter has ceased as of 25 March 2008.
-
    * Main Download for both files:
 
-
    * Windows version:
 
-
    * OSX version:
 
-
    * Linux version:
 
-
Note: Sun Java 1.4 or later needed. Linux version needs mencoder installed.
+
=== Avidemux ===
-
=== tablet-encode ===
+
Avidemux is an open source video processing program. It works on almost all known operating systems. The Windows and Linux (qt) versions support preset config files for x264 encoding.
-
To generate video which will play correctly on Nokia tablets, the easiest method is to use [http://mediautils.garage.maemo.org/tablet-encode.html tablet-encode], which wraps [http://www.mplayerhq.hu/ mencoder from MPlayer]. The program offers a number of predetermined sets of options to optimise image quality, framerate and size.
+
[http://depeje.net/maemo/N900_x264.xml N900 optimized preset for avidemux x264] will encode for the N900. It is essentially a baseline profile for h264.
 +
*In Windows: put this file in Application Data/avidemux/x264/
 +
*In linux: put the file in ~/.avidemux/x264/
-
=== MediaCoder ===
+
Set the video codec: "MPEG-4 AVC", click the "configure" button underneath it and choose the downloaded "Configuration". Using the "Filters" button add a resize filter to your video if needed (800x448 is optimal). Finally set MP4 as "Format".
-
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.
+
== General Notes on Codec Usage ==
-
Nokia N800 Video Convert
+
-
Very easy to install and use, great results. Uses the MEncoder engine.
+
Two of the most popular codecs are H.263/XVid and H.264. As the Xvid and AVI container formats have become deprecated, the latest version of Handbrake (0.9.4) has dropped support for these formats. DivX have also switched to H.264 since version 7. At a given file size, H.264 will result in better looking video, at a cost in increased encoding time. If you wish to encode in Xvid, you can still download the older Handbrake 0.9.3 or other Xvid encoding-software.
-
=== Handbrake ===
+
=== Supported Codecs ===
-
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.
+
A full list of supported codecs can be found in the [[N900 Media Support]] page.
-
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).
+
==== H.264 ====
-
Tested on Mac OS X
+
H.264 video (MPEG4 Part 10) is supported natively by the N900. The format has a variety of profiles; the N900 supports the Baseline 3.0 profile, which is what Handbrake will encode at by default.
-
=== SUPER ===
+
More information on H.264 can be found on [[:wikipedia:H.264/MPEG-4_AVC|Wikipedia]]
-
"SUPER © Simplified Universal Player Encoder & Renderer.....SUPER © plays & encodes very fast full length movies to any other format without any time or function limitation."
+
=== Anamorphic Video ===
-
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.
+
The native Media Player in the N900 does not support Anamorphic Video. DVDs are stored at a resolution of 720x480 (NTSC) or 720x576 (PAL) 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, or you can disable Anamorphic encoding entirely.
-
== Creating Streamable Video Yourself ==
+
=== Streaming Video ===
-
As maemo supports [[Real Video streams]], you can use HelixProducer to create them from your own inputs.
+
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 will see a lot of pausing and buffering messages. It seems that the highest bitrate it will stream happily is about 1 MBit/s including audio. The preset is optimized for local storage - you can tweak it to produce smaller files if you need to stream.
-
== Manual conversion instructions ==
+
=== Resolution ===
-
=== Mencoder ===
+
As mentioned above, you will 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.
-
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.  
+
==== 4:3 DVDs (Aspect Ratio 1.33) ====
-
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.
+
4:3 DVD video is easy to handle. Just resize to 640x480.
-
mencoder infile.avi -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4 -vf scale=352:208 -ffourcc DIVX -ofps 15 -o outfile.avi
+
==== 16:9 DVDs (Aspect Ratio 1.78) ====
-
This will generate a 15fps 352x208 avi file.
+
For 16:9 DVDs, it is 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.  If you want smaller file sizes, you can choose to encode your video at other 16:9 compatible resolutions such as 720x416, 704x400 or 640x368 and the N900 will scale the display back up to 800x448, although there may be some loss of image quality.  Please note, these resolutions are not perfect 1.78 aspect ratio, but are the nearest to whilst maintaining widths and heights that are divisible by 16, which improves encoding efficiency.
-
The following mencoder command line will make smaller videos:
+
==== Letter box DVDs ====
-
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
+
Occasionally, you will 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 will need to use handbrake's crop feature to cut out the black bars. This is a pretty involved process because you are 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, the vertical resolution will be even lower (272 and 306 respectively for 2.35:1 content)
-
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):
+
==== SD sources ====
-
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
+
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, or shrink it to 800x448 as with DVDs.
-
The differences are the block detection method (mbd=1) and a capped bitrate see man mencoder for more options
+
==== HD sources ====
-
=== ffmpeg ===
+
If you are scaling down an HD source, you will 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 pixels - just set the width to 800 and maintain the aspect ratio. Essentially all HD content has square pixels.
-
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:
+
=== N900 Notes ===
-
ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -s 176:144 -b 200 -pass 1 outfile.avi
+
The N900 supports a native resolution of 854x480 and does not support 1280x720. The actual limit is unknown, but using a resolution larger than the native resolution is not recommended as the resolution would be larger than the screen and therefore inefficient.
-
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):
+
=== N770, N800/810 Notes ===
-
ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -vtag DIVX -s 176:144 -b 200 -pass 1 outfile.avi
+
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.
-
ffmpeg -i infile -vcodec mpeg4 -acodec mp3 -vtag DIVX -s 176:144 -b 200 -pass 2 outfile.avi
+
-
=== transcode ===
+
The demo video that comes with the N800 is encoded at 600 kbps, with a frame rate of 30 fps and a resolution of 400x240 pixels. To calculate the pixels per second, the equation is 400x240x30 = 2.88 Megapixels/second.
-
I just converted a DVD using transcode using the following command line:
+
[http://talk.maemo.org/showthread.php?p=287229#post287229 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.
-
transcode -i /dev/dvd \
+
For the Nokia 770, 1.52 Megapixels/second is achievable, but again, this depends on the complexity of the action.
-
          - 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.
+
The standard media player has some limitations:
-
I used the transcode package with Debian unstable.
+
* Horizontal and vertical dimensions must be multiples of 16.
 +
* Video data rate and resolution is limited to about 800 kbps and 400x240 pixels (352x288 on the 770).
 +
* Audio must be at 44.1 kHz or lower (performance drops dramatically with 48 kHz audio).
 +
* It does not support external subtitles, so they must be hardcoded.
 +
* DivXs need a FOURCC of "DIVX" rather than "DX50".
-
afterwards, I fixed the FOURCC with
+
== Audio Encoding ==
-
avifix -i output.avi -F DIVX
+
=== Standard Audio Codecs ===
-
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.
+
==== AAC ====
-
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:
+
AAC is supported natively by the Media Player in the N900. AAC is better than MP3 at the same bitrate, so you should generally choose AAC unless you require backwards-compatability to older devices.
-
transcode -i /dev/dvd \
+
The N900 will playback without difficulty a 48 kHz, 160 kbit/sec Dolby Prologic II stream in AAC format (encoded from an AC3 5.1 source).
-
          - 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.
+
==== MP3 ====
-
Additional informations regarding transcode and IT 2006 beta :
+
MP3 is supported natively by the Media Player in the N900.
-
I suggest using the following command-line :
+
=== Extra Audio Codecs ===
-
transcode -i /dev/dvd \
+
It is possible to add extra audio codec support to the N900 by installing the  [http://maemo.org/downloads/product/Maemo5/decoders-support/ Decoders Support] package from Maemo Extras.
-
          - x dvd \
+
 
-
          - T 1,-1 \
+
==== AC3 ====
-
          - a 0  
+
 
-
          - Z 352x208 \
+
The Decoders Support package adds AC3 audio support. AC3 audio is interesting because most DVD audio tracks are encoded in this format. 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 are not going to be able to take advantage of surround sound - meaning that storing a full 5.1 audio track wastes space.
-
          - -keep_asr \
+
 
-
          - y ffmpeg \
+
=== Older devices ===
-
          - F mpeg4 \
+
 
-
          - w 300 \
+
As for the audio subsystem, MP3 at 128 kbps works well with older tablets like the N700 and N800/810. 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.
-
          - N 0x55 \
+
 
-
          - b 48 \
+
== Container Formats ==
-
          - R 1 \
+
 
-
          - o output.avi
+
The "container" is what holds the video and audio together and instructs the playing software what to do with them. Different types of audio and video formats exist in one container package, which you will see as for example ".avi" for the Audio-Video Interleave container.
 +
 
 +
=== Supported Container Formats ===
 +
 
 +
==== MP4 ====
 +
 
 +
Supported out of the box in the N900 and is the preference for video container formats. MP4 files can be played natively using the built-in Media Player. MP4 also supports chapters which are encoded by default in Handbrake.
 +
 
 +
While Media Player does not support seeking through an MP4 video file by chapter, it has no problem playing MP4s that contain them. It is better therefore to leave them in, as Chapter support may be included in future updates to Media Player.
 +
 
 +
==== AVI ====
 +
 
 +
AVI is supported out of the box on the N900; however, MP4 is superior in many ways and should be your preference unless you require backwards compatability. AVI is deprecated as a container and support has been dropped by Handbrake since version 0.9.4. DivX also switched to using the MKV container since 2008. AVI files can be played natively using the built-in Media Player.
 +
 
 +
==== MKV ====
 +
 
 +
MKV is a superior format to both AVI and MP4, but is not fully supported as yet by the native Media Player in the N900. It supports multiple audio tracks, multiple subtitle tracks along with chapter support and more features.
 +
 
 +
Support can be added by [http://maemo.org/downloads/product/Maemo5/decoders-support/ downloading the Decoders Support package] from Maemo Extras. However, MKV files will only play with mplayer which is still in development for Maemo 5/ N900. As such, it is not recommended at this time and there are significant performance costs when not using the built-in Media Player.
 +
 
 +
== Subtitles ==
 +
 
 +
Subtitle support is one area where options are severely limited - the tablet's media player does not handle them. So, the only choice available is 'burned' subtitles - where Handbrake renders them into the video stream.
 +
 
 +
== Media Players ==
 +
 
 +
=== Media Player ===
 +
 
 +
Media Player is the native N900 media player and has the primary advantage of being integrated into the UI and have DSP hardware acceleration. If you choose one of the alternatives, you lose this advantage and have to deal with increased battery usage and other problems. It is preferential for your video file to be playable on the native Media Player.
 +
 
 +
=== mplayer ===
 +
 
 +
mplayer is currently in development for the N900. It supports MKV playback and subtitles, but must be used from either the command-line or using a front-end like SiB or KMPlayer. However, despite its support for MKV, there is a significant increase in CPU usage due to the lack of hardware acceleration compared to the native player at this time.
 +
 
 +
== Manual conversion instructions ==
-
and
+
{{main|Manual video encoding}}
-
transcode -i /dev/dvd \
+
These tools offer manual conversion for those who need lots of customization options or just like getting down to the nitty-gritty.
-
          - 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.
+
== Further reading ==
 +
* [http://www.aneesoft.com/tutorials/video-converter-tutorials.html Convert videos for Nokia Phones]
 +
* [http://www.ifunia.com/how-tos/handbrake-presets-for-ipad-iphone4.html Handbrake Presets for iPhone 4 and iPad]
 +
* [http://www.ipodvideosconverter.com/ Ipod Video Converter]
 +
* [http://www.icoolsoft.com/ipad-video-converter/ Ipad Video Converter]
 +
* [[Manual video encoding]]
-
[[Category:Users]]
+
[[Category:Media]]
-
[[Category:Midgard wiki]]
+
[[Category:Wiki page of the day]]
 +
[[Category:Power users]]

Latest revision as of 18:23, 20 March 2012

Contents

[edit] 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 pixels) 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 pixels. 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.

[edit] Encoding Software

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.

[edit] Handbrake

Main article: Ripping DVDs with 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.

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 it is worth using settings more closely tailored to the device's capabilities.

Image:Ambox_notice.png
Note for more recent builds of Handbrake you must disable "Weighted P-frames" or the output will be Main Profile.

[edit] Arista

Arista is a video conveter supporting out-of-the-box N900. It works basing on presets, among which are presets for N900. No need to download anything more.

It's only known to support Linux. But, because it is written in PyGTK, it may be set up to run on Windows & MacOSX as well.

[edit] 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.

[edit] Media Converter

MediaConverter is a Java graphical application with several presets for transcoding video for the N800 or 770. 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.

[edit] viDrop

viDrop is a free and 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. It works on Linux and Windows, and supports batch processing, profiles and embedding subtitles, among other features.

[edit] Nokia Internet Tablet Video Converter

Main article: ITVC architecture


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.


[edit] Avidemux

Avidemux is an open source video processing program. It works on almost all known operating systems. The Windows and Linux (qt) versions support preset config files for x264 encoding.

N900 optimized preset for avidemux x264 will encode for the N900. It is essentially a baseline profile for h264.

  • In Windows: put this file in Application Data/avidemux/x264/
  • In linux: put the file in ~/.avidemux/x264/

Set the video codec: "MPEG-4 AVC", click the "configure" button underneath it and choose the downloaded "Configuration". Using the "Filters" button add a resize filter to your video if needed (800x448 is optimal). Finally set MP4 as "Format".

[edit] General Notes on Codec Usage

Two of the most popular codecs are H.263/XVid and H.264. As the Xvid and AVI container formats have become deprecated, the latest version of Handbrake (0.9.4) has dropped support for these formats. DivX have also switched to H.264 since version 7. At a given file size, H.264 will result in better looking video, at a cost in increased encoding time. If you wish to encode in Xvid, you can still download the older Handbrake 0.9.3 or other Xvid encoding-software.

[edit] Supported Codecs

A full list of supported codecs can be found in the N900 Media Support page.

[edit] H.264

H.264 video (MPEG4 Part 10) is supported natively by the N900. The format has a variety of profiles; the N900 supports the Baseline 3.0 profile, which is what Handbrake will encode at by default.

More information on H.264 can be found on Wikipedia

[edit] Anamorphic Video

The native Media Player in the N900 does not support Anamorphic Video. DVDs are stored at a resolution of 720x480 (NTSC) or 720x576 (PAL) 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, or you can disable Anamorphic encoding entirely.

[edit] 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 will see a lot of pausing and buffering messages. It seems that the highest bitrate it will stream happily is about 1 MBit/s including audio. The preset is optimized for local storage - you can tweak it to produce smaller files if you need to stream.

[edit] Resolution

As mentioned above, you will 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.

[edit] 4:3 DVDs (Aspect Ratio 1.33)

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

[edit] 16:9 DVDs (Aspect Ratio 1.78)

For 16:9 DVDs, it is 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. If you want smaller file sizes, you can choose to encode your video at other 16:9 compatible resolutions such as 720x416, 704x400 or 640x368 and the N900 will scale the display back up to 800x448, although there may be some loss of image quality. Please note, these resolutions are not perfect 1.78 aspect ratio, but are the nearest to whilst maintaining widths and heights that are divisible by 16, which improves encoding efficiency.

[edit] Letter box DVDs

Occasionally, you will 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 will need to use handbrake's crop feature to cut out the black bars. This is a pretty involved process because you are 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, the vertical resolution will be even lower (272 and 306 respectively for 2.35:1 content)

[edit] 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, or shrink it to 800x448 as with DVDs.

[edit] HD sources

If you are scaling down an HD source, you will 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 pixels - just set the width to 800 and maintain the aspect ratio. Essentially all HD content has square pixels.

[edit] N900 Notes

The N900 supports a native resolution of 854x480 and does not support 1280x720. The actual limit is unknown, but using a resolution larger than the native resolution is not recommended as the resolution would be larger than the screen and therefore inefficient.

[edit] N770, N800/810 Notes

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 600 kbps, with a frame rate of 30 fps and a resolution of 400x240 pixels. 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.

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 800 kbps and 400x240 pixels (352x288 on the 770).
  • Audio must be at 44.1 kHz or lower (performance drops dramatically with 48 kHz audio).
  • It does not support external subtitles, so they must be hardcoded.
  • DivXs need a FOURCC of "DIVX" rather than "DX50".

[edit] Audio Encoding

[edit] Standard Audio Codecs

[edit] AAC

AAC is supported natively by the Media Player in the N900. AAC is better than MP3 at the same bitrate, so you should generally choose AAC unless you require backwards-compatability to older devices.

The N900 will playback without difficulty a 48 kHz, 160 kbit/sec Dolby Prologic II stream in AAC format (encoded from an AC3 5.1 source).

[edit] MP3

MP3 is supported natively by the Media Player in the N900.

[edit] Extra Audio Codecs

It is possible to add extra audio codec support to the N900 by installing the Decoders Support package from Maemo Extras.

[edit] AC3

The Decoders Support package adds AC3 audio support. AC3 audio is interesting because most DVD audio tracks are encoded in this format. 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 are not going to be able to take advantage of surround sound - meaning that storing a full 5.1 audio track wastes space.

[edit] Older devices

As for the audio subsystem, MP3 at 128 kbps works well with older tablets like the N700 and N800/810. 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.

[edit] Container Formats

The "container" is what holds the video and audio together and instructs the playing software what to do with them. Different types of audio and video formats exist in one container package, which you will see as for example ".avi" for the Audio-Video Interleave container.

[edit] Supported Container Formats

[edit] MP4

Supported out of the box in the N900 and is the preference for video container formats. MP4 files can be played natively using the built-in Media Player. MP4 also supports chapters which are encoded by default in Handbrake.

While Media Player does not support seeking through an MP4 video file by chapter, it has no problem playing MP4s that contain them. It is better therefore to leave them in, as Chapter support may be included in future updates to Media Player.

[edit] AVI

AVI is supported out of the box on the N900; however, MP4 is superior in many ways and should be your preference unless you require backwards compatability. AVI is deprecated as a container and support has been dropped by Handbrake since version 0.9.4. DivX also switched to using the MKV container since 2008. AVI files can be played natively using the built-in Media Player.

[edit] MKV

MKV is a superior format to both AVI and MP4, but is not fully supported as yet by the native Media Player in the N900. It supports multiple audio tracks, multiple subtitle tracks along with chapter support and more features.

Support can be added by downloading the Decoders Support package from Maemo Extras. However, MKV files will only play with mplayer which is still in development for Maemo 5/ N900. As such, it is not recommended at this time and there are significant performance costs when not using the built-in Media Player.

[edit] Subtitles

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

[edit] Media Players

[edit] Media Player

Media Player is the native N900 media player and has the primary advantage of being integrated into the UI and have DSP hardware acceleration. If you choose one of the alternatives, you lose this advantage and have to deal with increased battery usage and other problems. It is preferential for your video file to be playable on the native Media Player.

[edit] mplayer

mplayer is currently in development for the N900. It supports MKV playback and subtitles, but must be used from either the command-line or using a front-end like SiB or KMPlayer. However, despite its support for MKV, there is a significant increase in CPU usage due to the lack of hardware acceleration compared to the native player at this time.

[edit] 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.

[edit] Further reading