68 lines
1.9 KiB
Markdown
68 lines
1.9 KiB
Markdown
# Subtytle
|
|
|
|
A Subtitle library for rust.
|
|
For right now only [ASS](https://breezewiki.4o1x5.dev/fileformats/wiki/SubStation_Alpha) (SubStation Alpha) is implemented, but hopefully there will be more time in the future to make room for SRT,VTT and SUB(microdvd).
|
|
|
|
# Features
|
|
|
|
- Parsing ASS from `str`
|
|
|
|
```rust
|
|
use std::fs::File;
|
|
use std::io::{self, Read};
|
|
use subtytle::ass::AssSubtitle;
|
|
|
|
fn main() {
|
|
let path = "subtitles.ass";
|
|
let mut file = File::open(path).expect("Failed to read in file");
|
|
let mut contents = String::new();
|
|
file.read_to_string(&mut contents).expect("Failed to read string");
|
|
let ass_decoded = AssSubtitle::from_str(contents).unwrap();
|
|
|
|
Ok(())
|
|
}
|
|
```
|
|
|
|
- Parsing of SRT events into ass events
|
|
|
|
```rust
|
|
use std::fs::File;
|
|
use std::io::{self, Read};
|
|
use subtytle::ass::Event;
|
|
|
|
fn main() {
|
|
let path = "subtitles.srt";
|
|
let mut file = File::open(path).expect("Failed to read in file");
|
|
let mut contents = String::new();
|
|
file.read_to_string(&mut contents).expect("Failed to read string");
|
|
let list_of_events = Event::from_srt(contents).unwrap();
|
|
|
|
Ok(())
|
|
}
|
|
```
|
|
|
|
# Limitations
|
|
|
|
I have yet to find the original specifications of the Sub Station Alpha script format, therefore I've used [this one](http://www.tcax.org/docs/ass-specs.htm). I have no idea which fields are actually optional and which are not. Also there is many left out like:
|
|
|
|
```
|
|
ScaledBorderAndShadow: yes
|
|
Last Style Storage: Default
|
|
Video File: ?dummy:23.976000:40000:640:480:47:163:254:
|
|
Video Aspect Ratio: 0
|
|
Video Zoom: 8
|
|
Video Position: 0
|
|
```
|
|
|
|
# Bugs department
|
|
|
|
Since the code is hosted on a private git instance (as of right now) any bugs shall be discussed in [4o1x5's project room](https://matrix.to/#/#projects:4o1x5.dev).
|
|
|
|
## License
|
|
|
|
Licensed under the [MIT](https://choosealicense.com/licenses/mit/) license.
|
|
|
|
## Contribution
|
|
|
|
Currently this library does not accept any contributors, as it's hosted on a private git server.
|