How to embed .idx subtitles into an mp4 or avi file with mencoder
I usually watch movies with subtitles on my cellphone but before that I have to transcode the avi to an mp4 with the subtitles “burnt” on the movie, not as a separate file. Recently I came across a movie with subtitles in two files, one .idx and one .sub instead of the common .srt file. And converting the movie to mp4 with that vobsub subtitles embedded wasn’t easy.
First of all I tried converting the idx/sub pair to a single srt. Although possible it’s a pain as long as you have identify the chars with an OCR adding the new ones by hand. Then I tried to get mencoder to read the .idx subs directly as I do with srt. Didn’t work. Finally I came up with a workaround: Merging the avi and the .idx into one Matroska (mkv) file and transcoding that Matroska to mp4 then.
Installing the necessary tools:
sudo apt-get install mencoder mkvtoolnix
Merging the files:
mkvmerge -o video.mkv video.avi video.idxThis is the output:
mkvmerge v2.4.1 ('Use Me') built on Dec 13 2008 21:03:46
'video.avi': Using the AVI demultiplexer. Opening file. This may take some time depending on the file's size.
'video.idx': Using the VobSub subtitle reader (SUB file 'video.sub').
'video.avi' track 0: Using the MPEG-4 part 2 video output module.
'video.avi' track 1: Using the MPEG audio output module.
'video.idx' track 0: Using the VobSub subtitle output module (language: eng).
'video.idx' track 1: Using the VobSub subtitle output module (language: fre).
'video.idx' track 2: Using the VobSub subtitle output module (language: spa).
The file 'video.mkv' has been opened for writing.
Progress: 100%
The cue entries (the index) are being written...
Muxing took 23 seconds.As you can see the idx file contains subs for three languages, as long as we want to overlay the English one we will pass mencoder the option -slang eng:
mencoder -slang eng -of lavf -lavfopts format=mp4 -oac lavc -ovc lavc -lavcopts aglobal=1:vglobal=1:acodec=libfaac:vcodec=mpeg4:abitrate=128:vbitrate=1200:keyint=250:mbd=1:vqmax=10:lmax=10 -vf harddup 'video.mkv' -o 'video.mp4'
And the resultang mp4 should have the idx subtitles rendered inside, not in a very beautiful way but works : ).
English
Español
Serena
17 Jun, 2009
very useful!!
thanks a lot!!
:)
tanclo
20 Nov, 2009
disagree – command line is very beautiful and sexy. this is JUST what i needed. thanks
Hanjo
5 Jan, 2010
Lovely – Thanks a lot, works just perfectly for me as well! Tried to convert the idx and sub-files to srt before but was too much of a struggle due to the fuzzy text-recognition…
atul
25 May, 2010
i watch lots of movie on my cell that’s 5800 xm, but till today not fond any gui or software which can help me in watching mp4 movie with subtitle mux or burned can any of you suggest how can it be done. plz i very desperate to know how it can be done. if possible step by step procdure with be most helpful.
atul
27 May, 2010
I usually watch movies with subtitles on my cellphone but before that I have to transcode the avi to an mp4 with the subtitles “burnt” on the movie, not as a separate file. Recently I came across a movie with subtitles in two files, one .idx and one .sub instead of the common .srt file. And converting the movie to mp4 with that vobsub subtitles embedded wasn’t easy.
plz can u tell me how do u managed to do this much. i tried everything but no success till date. plz lz plz
j
5 Jun, 2010
Do you have instruction for doing this with windows?
Instant Payday Cash Loan
27 Apr, 2011
Hi, I think your blog might be having browser compatibility issues. When I look at your blog in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!