A Rust library for parsing and decoding Blu-ray Presentation Graphic Stream (PGS/SUP) subtitle files.
Add to your Cargo.toml:
[dependencies]
pgs-parse = "0.1.3"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);
}
}Export a subtitle frame to a TIFF image:
cargo run --example parse_sup_file -- -p examples/data/BluRay.sup -t output.tiff -d 0Read and inspect segments from a SUP file:
cargo run --example read_sup_filecargo test