Reputation: 121
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.
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.
Upvotes: 12
Views: 26194
Reputation: 1288
To extract just the subtitle stream to a file using ffmpeg
, this command seems to do the trick:
ffmpeg -i video.mkv -map 0:s -c copy subtitles.sup
The .sup
extension is accepted by my ffmpeg (v5.0) to extract these subtitles without error.
Then you can use Chortos-2's answer, with a compatible OCR program to convert it to text subtitles.
Upvotes: 10
Reputation: 1123
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.
Upvotes: 18