ssa_parser

Crates.iossa_parser
lib.rsssa_parser
version0.1.0
created_at2024-11-12 14:13:44.67826+00
updated_at2024-11-12 14:13:44.67826+00
descriptionA ssa subtitle parsing library
homepage
repositoryhttps://github.com/mikai233/subtitle_parser
max_upload_size
id1444998
size70,293
mikai233 (mikai233)

documentation

README

ssa and ass subtitle parser

example

fn main() -> anyhow::Result<()> {
    let path = "your .ass file path here";
    let mut file = ssa_parser::file::File::from_file(path)?;
    let offset_duration = Duration::from_secs(1);
    for event in file.events.iter_mut() {
        if let Some(start) = event
            .get_mut(EventFormat::Start)
            .and_then(Value::as_duration_mut)
        {
            *start += offset_duration;
        }
        if let Some(end) = event
            .get_mut(EventFormat::End)
            .and_then(Value::as_duration_mut)
        {
            *end += offset_duration;
        }
    }
    Ok(())
}
Commit count: 17

cargo fmt