Crate vobsub [] [src]

This crate reads DVD subtitles in VobSub format. These are typically stored as two files: an *.idx file summarizing the subtitles, and an MPEG-2 Program Stream containing the actual subtitle packets.

Example code

extern crate image;
extern crate vobsub;

let idx = vobsub::Index::open("examples/example.idx").unwrap();
for sub in idx.subtitles() {
    let sub = sub.unwrap();
    println!("Time: {:0.3}-{:0.3}", sub.start_time, sub.end_time);
    println!("Always show: {:?}", sub.force);
    println!("At: {}, {}", sub.coordinates.left(),;
    println!("Size: {}x{}", sub.coordinates.width(), sub.coordinates.height());
    let img: image::RgbaImage = sub.to_image(idx.palette());

    // You can save or manipulate `img` using the APIs provided by the Rust
    // `image` crate.


Performance in debug mode is poor; compile with --release before benchmarking.


The initial version of this library is focused on extracting just the information shown above, and it does not have full support for all the options found in *.idx files. It also lacks support for rapidly finding the subtitle associated with a particular time during playback.


This library is distributed under the CC0 1.0 Universal public domain grant (plus license), with the exception of examples/example.sub, which contains the first two lines of subtitles from a film as example data.

Background & References

VobSub subtitles consist of a simple textual *.idx file, and a binary *.sub file. The binary *.sub file is essentially an MPEG-2 Program Stream containing Packetized Elementary Stream data, but only for a single subtitle track.

Useful references include:

There are also any number of open source implementations of subtitles decoders which might be useful once you get past the Program Stream and PES wrappers.

There are two closely-related formats that this library could be extended to parse without too much work:


Your feedback and contributions are welcome! Please see GitHub for details.



Location at which to display the subtitle.


The Error type.


A *.idx file describing the subtitles in a *.sub file.


A single subtitle.


An iterator over subtitles.



The kind of an error.



Return an iterator over the subtitles in this data stream.

Type Definitions


The 16-color pallette used by the subtitles.


Convenient wrapper around std::Result.