Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg extract hdmv pgs subtitles from mkv to srt

I've been trying to figure out how to extract hdmv pgs subtitles from an mkv file for a few days now. I must be doing something wrong. I'm a noob at this. Can someone please help? I think i need to set an encoder or set a codec parameter to fix the issue.

this is the subtitle I'm trying to rip

Stream #0:4(eng): Subtitle: hdmv_pgs_subtitle (default)
    Metadata:
      title           : Signs / Songs
      BPS-eng         : 7215
      DURATION-eng    : 00:22:43.946000000
      NUMBER_OF_FRAMES-eng: 96
      NUMBER_OF_BYTES-eng: 1230263
      _STATISTICS_WRITING_APP-eng: mkvmerge v28.0.0 ('Voice In My Head') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2018-10-22 23:45:00
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES

and the ffmpeg command i'm using is

ffmpeg -i "FILE PATH".mvk -map 0:4 "FILE PATH".srt

I've also tried

ffmpeg -i "FILE PATH".mkv -map 0:4 pgssub "FILE PATH".srt

ffmpeg -i "FILE PATH".mkv -map 0:4 hdmv_pgs_Subtitles "FILE PATH".srt

along with a few other variations and always get an error.

  • Subtitle encoding currently only possible from text to text or bitmap to bitmap
  • Unable to find a suitable output format for 'hdmv_pgs_subtitle'
  • Unsupported subtitles codec: dvd_subtitle
  • Could not find codec parameters for stream 4 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options
  • Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
  • or the srt file it creates is 0kb.

Can someone please tell me what i'm doing wrong and show me the correct code to use. I'm on a mac and i've also tried using MKVToolNix and get a weird binary file that doesn't work cause it's probably in the wrong format.

like image 290
breezybrea Avatar asked Jul 19 '20 06:07

breezybrea


People also ask

Can you convert PGS to SRT?

Here is how you can convert PGS to SRT using the Subtitle Edit program: Launch Subtitle Edit on your Windows PC. Click Open to import the PGS file. Hit the Format tab and select SRT as the output file type.

Where can I find PGS subtitles?

Go to https://www.nikse.dk/subtitleedit and download the app, install and launch it. Click File and import subtitle from MKV file. Or you can drag and drop the file into the program. Select the video file with PGS subtitles and open it by tapping Open, after which the OCR window pops up.

What are PGS subtitles?

A: Actually, PGS is not a text-based subtitle file type, it's just a timed sequence of graphic images. Just like when you extract subtitles from DVD, converting PGS to SRT, OCR (Optical Character Recognition) is a necessary process.


1 Answers

My understanding is that PGS is bitmap subtitles. In other words, it’s a bunch of pictures showing the subtitles that are simply placed on top of the video upon display.

Meanwhile, SRT is text subtitles: it is a plain text file that contains the text of each subtitle line and the times when the line is to be displayed.

To convert images to text, you need some sort of OCR (optical character recognition) software. FFmpeg does not support OCR, as far as I’m aware.

A brief search on the Web tells me that Subtitle Edit can extract PGS from MKV, run it through OCR and save the result as SRT. There are some guides for this on the Web, but if you have further questions, they are probably better suited for Super User.

like image 174
Chortos-2 Avatar answered Sep 30 '22 03:09

Chortos-2