Skip to content
mbolaricPublic

About

Parsing Presentation Graphic Stream (BluRay Subtitle Format - SUP files)

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

Presentation Graphic Stream (pgs-parse)

A Rust library for parsing and decoding Blu-ray Presentation Graphic Stream (PGS/SUP) subtitle files.

Build Status Crates.io

Installation

Add to your Cargo.toml:

[dependencies]
pgs-parse = "0.1.3"

Usage

use pgs_parse::{PgsParser, PgsDisplaySetState};

let parser = PgsParser::parse("subtitles.sup")?;

for ds in parser.get_display_sets() {
    if ds.state() == PgsDisplaySetState::Complete {
        // Decode RLE image: true for grayscale (ideal for OCR), false for 32-bit ARGB
        let pixels: Vec<Vec<u32>> = ds.get_decoded_image(true)?;
        let ods = ds.ods.as_ref().unwrap();
        println!("Subtitle frame: {}x{}", ods.width, ods.height);
    }
}

Running Examples

Export a subtitle frame to a TIFF image:

cargo run --example parse_sup_file -- -p examples/data/BluRay.sup -t output.tiff -d 0

Read and inspect segments from a SUP file:

cargo run --example read_sup_file

Testing

cargo test

About

Parsing Presentation Graphic Stream (BluRay Subtitle Format - SUP files)

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages