Wednesday, March 3, 2010

Howto: High Quality Fullscreen Video on the T-Mobile Sidekick 2008

If you have a sidekick 08 and want to watch high quality video on it you will want this bash script.

When I looked online at the tutorials for converting video to the 3gp format that the sidekick supports all the output looked really bad. The resolution and bitrate was so low it wasn't worth watching. So I looked of the 3GP format standard and found that it supports other higher resolutions, but none of them fit the sidekick screen perfectly.

The solution was to convert the video to one of the higher resolution versions and pad the video with black bars in the non-displayed off screen portions.

Here is the script, you will need ffmpeg and mplayer installed, as well as the windows binary version of ffmpeg that supports encoding the 3GP format.

Please note: This script is written in Bash, meaning that it is primarily for Linux users. This could easily be converted for windows users as well. I may do that in the future if I get enough requests. If you want a windows version, send me a tweet

#!/bin/bash # # Script: # Convert video to high quality 3GP format - http://www.tighelory.com # filename: sidekick_video.sh # 2010 Tighe Lory # # Requirements: # # You need to make the following directories: # ~/Video/Convert # ~/Video/Original # ~/Video/3gp # # You will also need ffmpeg and mencoder installed # # You will also need the binary windows version of ffmpeg that supports the 3gp format and wine installed. # Save the windows binary version to ~/.wine/drive_c/ffmpeg/ # # Place the videos you want to convert in the ~/Video/Convert directory cd ~/Video/Convert #Begin Section 1: convert AVI format files to 3GP format. for k in *.avi; do out=$(ls "$k" | sed -e 's/.avi//g') #First convert avi file 352x240 resolution ffmpeg -i "$k" -s 352x240 -r 29.97 -qscale 2 -ac 1 -ar 44100 -ab 128 -vcodec mpeg4 -f avi -vtag xvid -acodec mp3 ~/Video/Convert/"$out"_temp.avi #Now convert the converted file to 3gp format and add 24px black bars to the top and bottom of the video to make the final resolution 352x288 #the black bars will not be displayed on the sidekick, as the vertial resolution is 240px this is a trick to have almost full screen video. #This step uses the windows version of ffmpeg in wine, this is because the version of ffmpeg that I have does not support 3gp format. #If your version does you will not need to use this windows version. wine ~/.wine/drive_c/ffmpeg/ffmpeg.exe -i ~/Video/Convert/"$out"_temp.avi -padtop 24 -padbottom 24 -vcodec h263 -acodec aac -ac 1 -ar 44100 -b 700K -r 15 -ab 128 -y ~/Video/3gp/"$out".3gp #clean up when done. if [ $? -eq 0 ] ; then echo "~/Video/Convert/$out.3gp created" mv "$k" ../Original/ rm -v ~/Video/Convert/"$out"_temp.avi else echo "Error encoding" fi done #Begin Section 2: convert MKV format files to 3GP format. for k in *.mkv; do out=$(ls "$k" | sed -e 's/.mkv//g') #First convert the MKV file to AVI and turn softsubs to hardsubs mencoder "$k" -fontconfig -subfont-text-scale 3 -subfont-autoscale 3 -alang 0 -oac mp3lame -sid 0 -ovc xvid -xvidencopts pass=1 -o ~/Video/Convert/"$out"_temp1.avi #Now scale the avi file 352x240 resolution ffmpeg -i ~/Video/Convert/"$out"_temp1.avi -s 352x240 -r 29.97 -qscale 2 -ac 1 -ar 44100 -ab 128 -vcodec mpeg4 -f avi -vtag xvid -acodec mp3 ~/Video/Convert/"$out"_temp2.avi #Now convert the converted file to 3gp format and add 24px black bars to the top and bottom of the video to make the final resolution 352x288 wine ~/.wine/drive_c/ffmpeg/ffmpeg.exe -i ~/Video/Convert/"$out"_temp2.avi -padtop 24 -padbottom 24 -vcodec h263 -acodec aac -ac 1 -ar 44100 -b 700K -r 15 -ab 128 -y ~/Video/3gp/"$out".3gp #clean up when done. if [ $? -eq 0 ] ; then echo "~/Video/3gp/$out.3gp created" mv "$k" ../Original/ rm -v ~/Video/Convert/"$out"_temp1.avi rm -v ~/Video/Convert/"$out"_temp2.avi else echo "Error encoding" fi done