I downloaded a Korean movie, Changing Partners (official website) and to my surprise it was a .rmvb file. I personally prefer to play movies with VLC but this .rmvb file format is not supported. I need to wait for the next version of VLC but I want to watch this movie as soon as possible, possibly now or very soon.
I am kind of disgusted by software from RealMedia partly based on personal experience and partly based on what I read online.
I took some time to search for alternatives to run on the Mac OSX and I didn't find any. I know if I am running M$ Windows, I can use Real Alternative but no luck for me here.
Okay, fine, I'll download and install software from Real Media because I am desperate for some entertainment. I downloaded the Real Player 11 Beta and it was a whopping 13.3MB download. Alright, for broadband users this kind of file size is nothing but I am always amazed at software that is small and have tons of features. I guess the stereotypical example from me would be uTorrent. Why did I just mention uTorrent? I guess I just missed it since I am not using M$ Windows much these days.
Anyway, I got Real Player installed and tried to play it and after a few minutes I realised I didn't understand a word. It was all gibberish to me. They are talking in Korean! What a surprise! Okay then I need to look for subtitles. So I went to scour the Internet and all I found was websites waiting for me to download their malware so they can infect my Windows machine that I didn't have.
Hmm, what do to now? I looked into the folder that contained the downloaded files for the movie and there was a .rar file, waiting for me to uncompress it. Darn, there is no native support for rar compressed files in Mac OSX.
Oh yes, I remember that I have MacPorts installed, maybe I can find and install a command line utility for this. I did a search using the port search rar command and then found unrar utility and installed it using the sudo port install unrar.
I uncompressed the .rar file. Lo and behold there was a .srt file inside. I am bursting with joy until I realised that I have no idea how to load a subtitle file in the Real Player. I found a resource at captionkit that says how to do it but it didn't work (in fact that tip was for something else). After a while with more research I realised that the .rmvb file requires another 2 more files (.rt and .smil) for subtitling to work.
I googled for .srt to .smil converters but didn't find any. After a while I stumbled upon a few posts in the Doom9 forums that gave me hints on how to write my own .smil and .rt files.
So that is what I did, with some documentation provided by Real Media, I wrote some .rt and .smil files and tried to play it with the Real Player. It worked pretty well. If you know HTML, .rt and .smil files would look really familiar. Once I am pretty confident of my RealText knowledge I wrote a .srt to .rt converter in Python. The code is not very pretty and elegant but it works (feel free to use it and hack on it):
import sys
f = open(sys.argv[1])
print '<window duration="02:00:00" width="640" '
'bgcolor="black"><font color="white"><center>'
while True:
subtitle_number = f.readline()
if not subtitle_number:
print '</center></font></window>'
sys.exit(0)
time_data = f.readline()
begin, _ = time_data.split(' --> ')
begin = begin.strip().replace(',', '.')
print '<time begin="%s"/>' % begin
subtitles = []
while True:
subtitle = f.readline().strip()
if not subtitle:
break
subtitles.append(subtitle)
print '<br/>'.join(subtitles)
print '<clear/>'
The .rt file looks like this:
<window duration="00:56:00" width="640" bgcolor="black">
<font color="white">
<center>
<time begin="00:00:40.273" end="00:00:43.008"/>
Presented by Cinema Service Co., Ltd.<br/>
In association with CJ Entertainment Inc.
<clear/>
<time begin="00:00:43.009" end="00:00:44.669"/>
Produced by Cine2000
<clear/>
<time begin="00:00:46.046" end="00:00:49.879"/>
Executive Producer<br/>KANG Woo-suk
<clear/>
...
And this it not the end because a .smil file is needed to package and provide layout for the text stream (subtitling) and the video stream (the movie I want to watch so dearly). And the .smil file that I used looks like this:
<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:rn="http://features.real.com/2001/SMIL20/Extensions">
<head>
<layout>
<root-layout backgroundColor="black" width="640" height="330"/>
<region id="video_region" z-index="1"/>
<region id="text_region" height="50" bottom="0" z-index="2"/>
</layout>
</head>
<body>
<par>
<video src="postx-cp-a.rmvb" region="video_region"/>
<textstream src="postx-cp-a.rt" region="text_region"/>
</par>
</body>
</smil>
Once you have the .smil, .rt and .rmvb (obviously) files you are ready. Fire up your Real Media Player and then open the .smil file and you'll be able to watch your movie with subtitles.
There are still some problems though. I didn't spend the time to figure out transparent background for the text region for subtitles. And the subtitles will stay on the screen until the next one pops up. So some subtitles will stay on the screen for a long time if no one says anything. In fact there is a way around this but adding the feature to make it disappear at the correct time (.srt files have this information) will create another bug: some subtitles won't even show up. So this is actually a feature of my .srt to .rt converter so that all subtitles appear.
You also need to do some manual .smil and .rt hacking for different movie sizes and duration. If you don't have the correct values, it won't play nice.
Phew! That was probably one of my longer posts. I am thirsty. Hope someone enjoys my little adventure in subtitle hacking. I guess its not something you do every time you watch a movie.
Hmm, I still want to write more actually. I just want to say that I also used my .srt to .rt converter for another movie, this time a Chinese one and it worked fine! God bless programmers! ![]()

Recent Comments