Extract PGS Subtitles from MKV to PNG with FFmpeg

This article provides a straightforward, step-by-step guide on how to extract PGS (Presentation Graphic Stream) subtitles from an MKV video file and save them as individual, sequential PNG images using the powerful command-line tool FFmpeg. Since PGS subtitles are already image-based, FFmpeg allows you to easily demux and decode them directly into standard image files for editing, OCR (Optical Character Recognition), or archiving.

Step 1: Identify the Subtitle Stream Index

Before extracting, you need to find which stream inside your MKV file contains the PGS subtitles. Run the following command in your terminal:

ffmpeg -i input.mkv

Look through the output for the “Subtitle” streams. You will see a line that looks similar to this:

Stream #0:2: Subtitle: hdmv_pgs_subtitle (default)

In this example, the subtitle stream is indexed as 0:2 (the third stream of the first input file) or subtitle index 0:s:0 (the first subtitle stream).

Step 2: Extract the PGS Subtitles as PNG Images

Once you know the stream index, use the following FFmpeg command to extract the subtitle frames into PNG images:

ffmpeg -i input.mkv -map 0:s:0 output_%04d.png

Command Breakdown:

FFmpeg will process the file and save every individual PGS subtitle frame as a transparent PNG image in your current directory.