Transcoding how-to

This page contains useful information about how to do proper transcoding both for Nokia 770 and N800.

Video Player limitations

  • 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:
    • 352x288 for 770
    • 640x480 for N800
  • 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 below:
    • 288x160 for 770
    • 352x288 for N800
  • Audio must be at 48kHz or lower
  • External subtitles cannot be read so they have to be written inside the video frames
  • For a list of the supported formats you can check here.

Things to keep in mind

  • Don't exceed the max bandwidth
    See Max Bandwidth
  • Try to keep the frame-rate exactly as the original
    So the resulting clip looks as smooth as possible
  • Try to keep the aspect ratio of the original clip as much as possible
    So the resulting clip doesn't look distorted
  • Try to keep the aspect ratio of the device's screen
    To minimize the black frames at the edges of the screen
  • Try to keep the original clip's fame size
    So no scaling glitches are introduced

Natural frame-sizes

Nokia 770

  • 240 x 144
  • 352 x 208
  • 352 x 288
  • 176 x 144
  • 320 x 240

N800

The same as Nokia 770 plus:
  • 400 x 240
  • 640 x 480

Max bandwidth

There's a limit to how many macroblocks per second each device can handle properly:
  • 770: 352 * 288 * 15 = 1520640
  • N800: 640 * 480 * 15 = 4608000
Let's consider these examples on a N800:
  • 400 x 240 @ 25: 2400000: Less than 4608000, so it plays OK
  • 640 x 480 @ 25: 7680000: More than 4608000, it won't play fine

Script

This script tries to intelligently find the best video frame size that would look good in the desired device (N770 or N800) while trying to keep the same aspect ratio as the original clip, as well as trying to fit the aspect ratio of the device.

You'll need Ruby and mplayer to execute the script. It will generate the recommended mencoder command to run.

You can find it here

-i, --input
Input file
-o, --output
Output file
-q, --quality
The quality of the output clip (1..6)
-d, --device
The device for which the output shall be compatible {770,N800}
-v, --verbose
Run verbosely
Example:
./transcode -v -i phantom-limbs.divx
Generates:
 * Input: 640x352 [20:11], 23.976 fps, 1297760 kbps.
 * Output: 400x240 [5:3], 23.976 fps, 400 kbps.
 mencoder /data/shared/videos/phantom-limbs.divx -o phantom-limbs.avi \
 -srate 44100 -oac mp3lame -lameopts vbr=0:br=128 -af volnorm \
 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400 -ofps 23.976000 \
 -vf-add scale=400:240 -noidx
Please note how the algorithm finds an output size that follows the principles mentioned before:
  • Don't exceed the max bandwidth
    400 * 240 * 23.975 = 2301696 < 4608000
  • Try to keep the frame-rate exactly as the original
    Original: 23.976, New: 23.976
  • Try to keep the aspect ratio of the original clip as much as possible
    Original: 1.81, New: 1.66
  • Try to keep the aspect ratio of the device's screen
    Device: 1.66, New: 1.66
  • Try to keep the original clip's fame size.
    Original 640x352, New: 400x240 (Any bigger frame-size would result in a slow video)


Improve this page