1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! 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("../fixtures/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());
//! let coords = sub.coordinates();
//! println!("At: {}, {}", coords.left(), coords.top());
//! println!("Size: {}x{}", coords.width(), coords.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.
//!
//! ## 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:
//!
//! - [Program Stream](https://en.wikipedia.org/wiki/MPEG_program_stream) (PS)
//! - [Packetized Elementary Stream][PES] (PES)
//! - [DVD subtitles](http://sam.zoy.org/writings/dvd/subtitles/)
//! - [System Time Clock](http://www.bretl.com/mpeghtml/STC.HTM)
//!
//! [PES]: http://dvd.sourceforge.net/dvdinfo/pes-hdr.html
//!
//! 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:
//!
//! - Subtitles embedded in DVD-format video. These should contain the
//! same subtitle packet format, but the `*.idx` file is replaced by data
//! stored in an IFO file.
//! - Subtitles stored in the Matroska container format. Again, these use
//! the same basic subtitle format, but the `*.idx` file is replaced by
//! an internal, stripped-down version of the same data in text format.
//!
//! ## Contributing
//!
//! Your feedback and contributions are welcome! Please see
//! [GitHub](https://github.com/emk/subtitles-rs) for details.
// For error-chain.
extern crate cast;
extern crate error_chain;
extern crate env_logger;
extern crate image;
extern crate lazy_static;
extern crate log;
extern crate nom;
extern crate regex;
extern crate safemem;
pub use ;
pub use ;
pub use ;
pub use ;