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