This post is about how to hardcode srt format subfiles in a separate file into your videos using mencoder, with a specific emphasis on doing it for Chinese subtitles.
If you want to hardcode vobsub based subtitles, mencoder seems incapable of doing it, the only reliable way I’ve found thus far is to use Handbrake.
Update: VLC is also capable of it if you use it from the command line. It’s tricky tho. Here’s the command that worked for me:
/Applications/VLC.app/Contents/MacOS/VLC -I dummy -v "The Lost bladesman (donny yen).m4v" "vlc://quit" --start-time 225 --stop-time 240 --sout-transcode-soverlay --sub-track=0 --sout='#transcode{vcodec=mp4v,vb=400,scale=.5,acodec=mp4a,ab=96,channels=2}:std{access=file,mux=mp4,dst=lostblades.m4v}'
/Applications/VLC.app/Contents/MacOS/VLC -I dummy -v "The Lost bladesman (donny yen).m4v" "vlc://quit" --sout-transcode-soverlay --sub-track=0 --sout='#transcode{vcodec=mp4v,vb=600,scale=1,acodec=mp4a,ab=96,channels=2}:std{access=file,mux=mp4,dst=lostblades.m4v}'
http://automate-everything.com/lang/en/2009/05/how-to-embed-idx-subtitles-into-an-mp4-or-avi-file-with-mencoder/
Prerequisites:
mplayer installed on your mac via ports with this command:
sudo port install mplayer-devel +aa +mencoder_extras +osd +xvid +x264 +faac
To use Chinese subtitles you must have them encoded in a text encoding mencoder can understand, have a font that can render that text encoding, and then you must tell mencoder to actually use that text encoding. I made this happen with Chinese fonts by using one of Apple’s Chinese fonts, saving my subtitles file as utf8 and telling mencoder to use utf8 when rendering the subtitle. I had to disable fontconfig using the -nofontconfig option befause fontconfig did not seem to be properly supporting unicode (utf8) characters.
Merge Chinese subtitles (utf8 encoded) into the film. This made use of a Chinese font copied into ~/.mplayer/subfont.ttf. To be double sure I also edited ~/.mplayer/config to have font=~/.mplayer/subfont.ttf. The subtitle stream doesn’t actually get hardcoded in unless you specify sid -1 (or whatever ID your subtitle stream is. You can find the subtitle ID by doing mplayer -v on your movie file. You can also just use the -font option as in this example:
mencoder -utf8 -nofontconfig -font /Library/Fonts/Hiragino\ Sans\ GB\ W6.otf -sub Waiting.Alone.2005.DVDScr.XviD.MP3-NewMov.cht.srt -ss 5:00 -endpos 30 -ovc lavc -lavcopts vbitrate=1000 -oac copy Waiting.Alone\[独自等待\].avi -o WaitingAlone.chineseSubs.avi
The -nofontconfig is used so that you can properly specify the Chinese font.
mencoder -utf8 -nofontconfig "Kiss.Kiss-Bang.Bang[2005]DvDrip[Eng]-aXXo.avi" -sub "Kiss.Kiss-Bang.Bang[2005]DvDrip[Eng]-aXXo.srt" -sid 1 -ovc lavc -lavcopts vcodec=ffvhuff -oac copy -ss 5:00 -endpos 30 -o ~/Desktop/test.avi
mencoder /Users/nik/Desktop/torrents/waiting-alone/proper/simple.avi -sub /Users/nik/Desktop/torrents/waiting-alone/proper/simple.srt -sid 1 -subfont 'Helvetica' -subfont-text-scale 3.5 -ovc lavc -lavcopts vcodec=ffvhuff -oac copy -ss 5:00 -endpos 30 -o /Users/nik/Desktop/torrents/waiting-alone/proper/out.avi
Converting to iphone:
reference
mencoder wps-hearme-cd1.avi -ss 30 -endpos 15 -o test.mp4 -vf scale=480:-10,harddup -oac faac -faacopts mpeg=4:object=2:raw:br=128 -of lavf -lavfopts format=mp4 -ovc x264 -x264encopts nocabac:level_idc=30:bframes=0:threads=auto