8

How do I convert a hdmv_pgs_subtitle (which is image based) to a text based subtitle in a MKV file?

I have tried ffmpeg -i in.mkv -c:v copy -c:a copy -c:s mov_text out.mkv but that results with the following error:

Stream mapping:
  Stream #0:0 -> #0:0 (copy)  
  Stream #0:1 -> #0:1 (copy)  
  Stream #0:2 -> #0:2 (hdmv_pgs_subtitle (pgssub) -> mov_text (native))  

Error while opening encoder for output stream #0:2 - maybe incorrect > parameters such as bit_rate, rate, width or height

2 Answers 2

12
+50

Converting image based subtitles to text is a nontrivial process, as you will need some kind of OCR system to interpret the bitmaps and figure out what the corresponding text is. ffmpeg alone will not do that for you.

I am not aware of any app that will do the whole process in one go, for Linux/UNIX. However, this process should work:

  • Extract the subtitles with mkvextract or ffmpeg
  • Convert the PGS subtitles to DVD SUB format with BDSup2Sub
  • OCR the subtitles into SRT format with VobSub2SRT
  • Mux the subtitles back into an mkv file with mkvmerge or ffmpeg
3
  • I can't find a build of any of the linked tools Commented May 23, 2016 at 21:19
  • Unfortunately it seems bdnxml2srt has vanished from the Internet. I've updated the answer with a different process (going through the DVD subtitle format instead) that should work. All the tools for that one are available. Commented May 24, 2016 at 7:16
  • Is this still current? there are command-line tools like subtitle edit now Commented Dec 21, 2017 at 5:13
1

This also seems to work as an online tool, but you have to wait a bit if there is a queue.

To extract the subtitles file, you can use this:

ffmpeg -i input.mkv -c copy -map 0:2 sub.sup

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.