DVD player and subtitles
Often, one has a movie in AVI format or the like and wants to play it on a DVD player. Often one wants to add subtitles. In order to do that, in a modern DVD player, one has to just put the AVI file, say film.avi and the subtitle file, say film.srt in the same folder in a CD, DVD or USB drive. Both files should have exactly the same name, apart from the extension.
My DVD player sometimes recognises the subtitles and sometimes it does not At the beginning, I though it could be a problem with the subtitles format or even of the name of the file, which eventually may contain spaces or non-standard characters. However, I have just found out that, in fact, this is not the problem. The problem is related to character encoding. Most subtitle formats are plain text files. However, the encoding may be different. My DVD player appears to recognise only the ISO-8859-1 and US-ASCII character sets.
In order to convert you text file to ASCII or ISO-8859 you may first need to figure out what is the original character set:
$ file -i film.srt
film.srt: text/plain charset=utf-16
In this case the file has been encoded using the UTF-16 charset, which, apparently, is quite different from ASCII.
In order to convert it, we can use several Linux utilities such as iconv:
$ iconv -f UTF-16 -t ASCII film_old.srt > film.srt
If you need to find out which formats are recognised by iconv you can use:
$ iconv -l
Alternatively, most plain-text editors will allow you to chose among several character encoding options when saving a file.
Do not forget to give identical names to the video and subtitles files before writing them to a DVD, CD or USB pendrive.
If you wish, you can also embed the subtitles in the video, instead of having them as a separate file. This has two drawbacks: 1) You will not have the option not to display the subtitles; and 2) This requires recoding the video, which takes some time. However, recoding may be good to ensure that your DVD player will be able to correctly display the video and play the audio. Most DVD players have codecs for MPEG4 video and MP3 audio (unfortunately, both are proprietary formats).If you chose to recode, you can use mencoder:
$ mencoder -sub film.srt film.avi -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1000 -oac mp3lame -lameopts br=256:vol=1 -ffourcc DIVX -o film_with_subtitles.avi
However, this will not work unless a font type is configured in your mplayer configuration directory, for instance:
$ ln -s /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf ~/.mplayer/subfont.ttf
You can also use the options “-subpos 95" and/or “-subfont-text-scale 3” in order to control the position and the size of the font, respectively.
Obviously, if you do not wish to embed the subtitles, just omit the “-sub film.srt film.avi” option.
If you feel more confortable with a graphical interface, the program Avidemux is relatively straightforward.
Yet a third option would be to create a real video DVD from your video file. The program DeVeDe provides you an easy way to create a proper DVD with menus and subtitles. This takes time and requires plenty of space, but it will ensure full compatibility, quality and configurability.
Finally, you may need to synchronise your subtitles before using them. In Linux, there are several subtitle editors which make this task easy.