Showing posts with label Script. Show all posts
Showing posts with label Script. Show all posts

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

Thursday, June 4, 2009

How to: Convert Anime with Soft Subs to Hard Subs

I like to watch Japanese Television. fortunately for me there are numerous fansubbing groups out there that will subtitle these shows for my viewing pleasure. In the past most of these fansubbed videos were Hard Subbed AVIs encoded with the xvid codec. Since the subtitles are right int he video you can watch these videos on almost anything that would play avi videos (Palm, PSP, older computer, etc.)

Today most fansub groups are releasing their videos in Matroska mkv format with an h264 codec. This format allows the original video HD video to be untouched and the subtitles can be turned on and off by the viewer. These videos are much smaller, can have multiple languages, and are easier to produce.

My problem is that some of my devises like my ASUS eee netbook, PSP, etc. Either doesn't have the power to decode HD h264 video or display soft subtitles.

So I made this little bash script for my Gentoo Linux computer to convert these videos into hard subbed versions. It will also convert AVIs using h264 codec to xvid. Please let me know if you find this useful.

December 18, 2009 - Please note, there was an error in this script which I have corrected and highlighted the change in green. PS I also had to change the case in the file move path.

#!/bin/bash # # Script: # Soft Subs to Hard Subs - http://www.tighelory.com # filename: softsubs2hardsubs.sh # 2009 Tighe Lory # # Requirements: # # You need to make the following directories: # ~/Video/Convert # ~/Video/Original # ~/Video/xvid # # You will also need ffmpeg and mencoder installed # # Place the videos you want to convert in the Video/Convert directory cd ~/Video/Convert #Covert AVIs that use H264 for k in *.avi; do out=$(ls "$k" | sed -e 's/.avi//g') ffmpeg -i "$k" -qscale 4 -ar 24000 -ab 64 -r 29.97 -vcodec mpeg4 -f avi -vtag xvid -acodec mp3 ~/Video/xvid/"$out.avi" if [ $? -eq 0 ] ; then echo "~/Video/xvid/$out.avi created" mv "$k" ../Original/ else echo "Error encoding" fi done for k in *.mkv; do out=$(ls "$k" | sed -e 's/.mkv//g') mencoder "$k" -fontconfig -subfont-text-scale 3 -subfont-autoscale 3 -alang 0 -oac mp3lame -sid 0 -ovc xvid -xvidencopts pass=1 -o ~/Video/xvid/"$out.avi" if [ $? -eq 0 ] ; then echo "~/Video/xvid/$out.avi created" mv "$k" ../Original/ else echo "Error encoding" fi done

Download softsubs2hardsubs.sh