17

I downloaded a Greek subtitle for a movie, and this is what I see when I open it with Gedit.

enter image description here

Subtitle works great on VLC, all perfect. But what if I want to edit this subtitle with some Greek words? I instantly get an error about character encoding.

enter image description here

I hit retry and then VLC doesn't recognize the subtitles...

9 Answers 9

20

For subtitle edition/translation (text-based subtitles, that is), I strongly suggest Gaupol.

sudo apt-get install gaupol

Besides of gaupol, you can also try Subtitle Editor and Gnome Subtitles.

However, from the screenshots, it is clear that your .srt file is not encoded in Unicode.

As it turns out, iconv does change the encoding of the file to UTF-8, but the converted file will still have the same characters you see when opening in Gedit.

The solution I found is this:

  1. Open Gaupol and go to menu FileOpen or click on the button Open.
  2. There is a selection menu in the lower part of the open window, titled Character encoding. Click on Other... (last option).

    Character encoding option in Gaupol's open window

  3. Select an appropriate encoding for your file, e.g. Greek ISO-8859-7, and click on the button Accept.

    show character encoding dialog box

  4. Now open your .srt file and make sure all characters are correctly rendered. Otherwise, repeat the above procedure with another encoding. You can run the command file -bi yourfile.srt to determine the correct encoding of your file (although I've read the results are not necessarily exact).

  5. With your subtitle file open in the correct character encoding, now go to the menu FileSave as... and change the character encoding option (again, at the bottom of the window) to UTF-8 and save the file (possibly with a new name, for safety).

This same procedure of adding the codepage will work for Gedit. Yet I leave the instructions for Gaupol since this question is about subtitle files.

Good luck.

4
  • I already have gaupol, and it shows the words like my screenshots before (in unreadable letters). And as i said before, if i set UTF-8 as the new encoding, VLC doesn't recognize the subtitles.. Apr 3, 2013 at 19:27
  • you'll have to change encoding before being able to edit and shave as utf-8
    – carnendil
    Apr 3, 2013 at 20:29
  • Could you be a bit more specific? Yoy mean change encoding via save as? U mean change encode via terminal with "iconv"? Both tried, VLC will not recognise the subtitle after that Apr 4, 2013 at 16:50
  • I'm sorry, I had to get myself some Greek language subtitles in order to check. Indeed, iconv does the character encoding change, but the program will not substitute the characters that are shown when opened as UTF-8. Please check my updated answer. Cheers.
    – carnendil
    Apr 4, 2013 at 19:58
7
iconv -f ISO-8859-7 -t UTF-8  Input_file.srt   > Output_file.srt  

Open them from Kate editor you can see the proper text, if you still need to open them from Gedit, in other words, permanently change the codification run the above terminal command.

3
  • iconv, for what I was able to experiment, will change the encoding of the file, but will not substitute any of the contents, that is, only the characters that coincide between the source and target encodings will render correctly, all others will render according to how the target encoding understands them. See my answer and their comments.
    – carnendil
    Aug 22, 2013 at 0:31
  • thnks @carnendil what I said it was that it changes the codification because I am also Greek (English not mother language) ,obviously I meant encoding and only in the output file the input still stands in the directory, but can you be kind enough to implement it in a bash script ? should I go for the "for do. iconv ...done" loop? Aug 22, 2013 at 0:35
  • that kind of answer it, note that still have to change the encoding to utf-8 from video player preferences #! /bin/bash for file in *.srt do iconv -f ISO-8859-7 -t UTF-8 -o "$file.new" "$file" && mv -f "$file.new" "$file" done Aug 22, 2013 at 1:34
5

I'd recommend enca. Unlike gaupol, you can handle not only subtitle-files, but any text file.

  1. Install enca:

    sudo apt-get install enca
    
  2. To figure out the encoding of the file, see if enca can guess it:

    enca <file>
    

    or, if it fails and you know the language of the text file, than run for example

    enca -L ru <file>
    

    and see what it gives you. Get the list of supported languages from man enca.

  3. I'd recommend to convert to UTF-8, you can do it by running

    enconv -x utf8 <file>
    

    or, again, if enca cannot guess the language by

    enconv -L ru -x utf8 <file>
    

    that should do the trick.

1

The problem is that Gedit (and many other linux apps) don't recognize correctly the text's encoding. VLC on the other hand is most probably set to recognize it correctly (through "Subtitle preferences" tab), and that's why you don't have any problem there. The solution is simple:

You don't open the file by double-clicking it, but through Gedit's "Open" dialog. There, you can find at the bottom left side a drop-down for Encoding, in which "Automatically Detected" is selected by default. Set it to "Windows-1253" or "ISO-8859-7" and you're good to go, the file opens correctly (and you can then save it to UTF-8 to avoid future issues)

0

Another subtitle editor that allows for converting into different formats (and comes with tons of features) is Aegisub. It's native format (.ass) is supported by VLC Media Player as well as MPlayer and converting to it should fix encoding issues.

0

For translating SRT files you also can use DualSub. It is open-source (GPLv3) and cross-platform. It uses Google Translator.

0

For your general informations, now there is subtitle-index.org, it concentrates a lot of subtitles, rank them along multiple criterias (duration, spell check, lisibility, encoding), and offers the best one in direct download as UTF-8.

Working pretty fine, it avoids encoding problems which are pretty commons and annoying.

0

This is a Python3 function for converting any text files including subtitles into the ones with UTF-8 encoding.

def correctSubtitleEncoding(filename, newFilename, encoding_from='ISO-8859-7', encoding_to='UTF-8'):
    with open(filename, 'r', encoding=encoding_from) as fr:
        with open(newFilename, 'w', encoding=encoding_to) as fw:
            for line in fr:
                fw.write(line[:-1]+'\r\n')
0

You only need Excel to correct this. It is quite simple, just follow these few steps:

Open a new Excel sheet Go to "Data", "Get external data", "From text", and select your subtitle file. You may need to search for "all files" instead of leaving it on ".txt" only.

Then, you can select the right encoding in the following window. Try most of them and preview the result. You will have to pay attention to 2 things:

  • eliminate all delimiters, to keep you text in one piece
  • put the "column data format to "text" (otherwise, Excel could take the minus sign for a formula)
  • import the data from the cell you like (A1 is OK of course).

Your text is perfectly encoded in Excel. You just have to copy/paste it all in a new .srt file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .