rsubs-lib

Crates.iorsubs-lib
lib.rsrsubs-lib
version0.3.2
sourcesrc
created_at2022-12-21 22:27:03.544378
updated_at2024-06-13 08:42:15.608094
descriptionPure Rust subtitle manipulation and conversion library.
homepage
repositoryhttps://github.com/adracea/rsubs-lib
max_upload_size
id743492
size132,340
Alexandru Dracea (adracea)

documentation

https://docs.rs/rsubs-lib

README

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_from_file("./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_from_file("./tests/fixtures/test.vtt")
        .unwrap()
        .to_ass() // converts file to SSA/ASS
        .to_file("./tests/fixtures/test_1.ass")
        .unwrap();
    ssa::parse_from_file("./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
Commit count: 76

cargo fmt