#subtitle #convert #manipulate #sub #parser

rsubs-lib

Pure Rust subtitle manipulation and conversion library

5 releases

0.1.10 Nov 23, 2023
0.1.9 Aug 28, 2023
0.1.8 Jun 17, 2023
0.1.7 Feb 20, 2023
0.1.4 Dec 29, 2022

#1279 in Parser implementations

Download history 7/week @ 2024-01-15 24/week @ 2024-01-22 12/week @ 2024-01-29 12/week @ 2024-02-05 31/week @ 2024-02-12 10/week @ 2024-02-19 65/week @ 2024-02-26 182/week @ 2024-03-04 30/week @ 2024-03-11 83/week @ 2024-03-18 84/week @ 2024-03-25 38/week @ 2024-04-01 10/week @ 2024-04-08 19/week @ 2024-04-15

151 downloads per month
Used in 4 crates

MIT license

90KB
2K SLoC

rsubs-lib

ci clippy Crates.io Crates.io CodeCoverage

A rust library for converting and changing subtitles Currently a work in progress but it should be able to produce usable .srt,.vtt and .ssa/ass files from one another.

Usage:

use rsubs_lib::srt;
use rsubs_lib::ssa;
use rsubs_lib::vtt;
use rsubs_lib::Subtitle;
use std::str::FromStr;

fn main() {
    srt::parse("./tests/fixtures/test.srt".to_string())
        .unwrap() // Can read either a file or a string
        .to_vtt() // converts file to WEBVTT
        .to_file("./tests/fixtures/test_1.vtt") // Writes the converted subtitle to a file
        .unwrap();
    vtt::parse("./tests/fixtures/test.vtt")
        .unwrap()
        .to_ass() // converts file to SSA/ASS
        .to_file("./tests/fixtures/test_1.ass")
        .unwrap();
    ssa::parse("./tests/fixtures/test.ass".to_string())
        .unwrap()
        .to_srt() // converts file to SRT
        .to_file("./tests/fixtures/test_1.srt")
        .unwrap();
    // OR Using the simpler `Subtitle` enum
    let sub: vtt::VTTFile = Subtitle::from_str("./tests/fixtures/test.ass").unwrap().into();
    sub.to_file("./tests/fixtures/test.vtt").unwrap();
}

More examples are provided in the examples folder.

Current features:

  • Changing colors
  • Shifting timestamps
  • Changing line text
  • In SSA and VTT format changing line style is also possible

Dependencies

~2.5–4MB
~77K SLoC