Originally Posted by nima0102
But unfortunately this script can not merge unicode subtitle correctly
There should be no problem in unicode as long as you have set your locale properly and you are using the GNU versions of tr
, etc. The problem then is most likely a non-unicode encoding (e.g., ISO8859-6 for arabic scripts). The encoding problem itself has nothing to do with the merging of subtitles. For example,
mplayer -sub sub.srt vid.avi
should have the same output for the foreign subtitles as the merged version. The trick is to find the source encoding of the subtitles you already have. Or, you can get the bitmap subtitles (from e.g., the DVD) and OCR them directly (you need an OCR program which will detect Persian).
Another option (which if you’re using text subtitles still relies on correct encoding) is to use the gstreamer framework. Gstreamer applies things like subtitles as a filter or layer, so there is no limit to the number of subtitles at one time. The benefit here is that it will correctly handle bitmap and text subtitles, so there is no need to OCR a foreign script. It shouldn’t be too hard to create a gstreamer pipeline in whatever language you like.
For the simple example of 2 srt subtitles with OSS and Xv output:
gst-launch filesrc location=sub1.srt ! subparse ! top. \
filesrc location=sub2.srt ! subparse ! bot. \
filesrc location=vid.avi ! decodebin name=decoder \
decoder. ! queue ! audioconvert ! audioresample ! osssink \
decoder. ! textoverlay name=top valignment=top ! textoverlay name=bot valignment=bottom ! xvimagesink