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(), sub.coordinates.top());
    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

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

Limitations

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.

License

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:

Contributing

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

Structs

Coordinates

Location at which to display the subtitle.

Error

The Error type.

Index

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

Subtitle

A single subtitle.

Subtitles

An iterator over subtitles.

Enums

ErrorKind

The kind of an error.

Functions

subtitles

Return an iterator over the subtitles in this data stream.

Type Definitions

Palette

The 16-color pallette used by the subtitles.

Result

Convenient wrapper around std::Result.