Struct aspasia::WebVttSubtitle
source · pub struct WebVttSubtitle { /* private fields */ }
Expand description
WebVTT (.vtt) subtitle data
Implementations§
source§impl WebVttSubtitle
impl WebVttSubtitle
sourcepub fn builder(
) -> __WebVttSubtitleBuilder<(__Optional<Option<String>>, __Optional<Vec<WebVttCue>>, __Optional<Vec<String>>, __Optional<Vec<String>>)>
pub fn builder( ) -> __WebVttSubtitleBuilder<(__Optional<Option<String>>, __Optional<Vec<WebVttCue>>, __Optional<Vec<String>>, __Optional<Vec<String>>)>
Create a new WebVttSubtitle
Arguments
header
: Header (optional)cues
: List of cuesstyles
: List of styles (strings)regions
: List of regions (strings)
source§impl WebVttSubtitle
impl WebVttSubtitle
sourcepub fn header(&self) -> Option<&String>
pub fn header(&self) -> Option<&String>
Get header
Examples found in repository?
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
fn main() -> Result<(), Error> {
// We can directly specify the format to open a subtitle file
let vtt = WebVttSubtitle::from_path("/path/to/some.vtt")?;
// and then directly work with its data
println!("{}", vtt.header().cloned().unwrap_or_default());
// or we could use the more general interface to open (timed) subtitle files
let sub = TimedSubtitleFile::new("/path/to/file.srt")?;
// Move the underlying data out in order to access format-specific properties
// Note that if the format doesn't match, this will perform a conversion instead of just moving the data
let mut srt = SubRipSubtitle::from(sub);
// Now we can access format-specific methods like SubRipSubtitle::renumber()
srt.renumber();
// Access and modify events
for event in srt.events_mut() {
event.shift(600.into());
}
// Write the modified subtitle to file
srt.export("/path/to/output.srt")?;
Ok(())
}
sourcepub fn set_header(&mut self, header: impl Into<Option<String>>)
pub fn set_header(&mut self, header: impl Into<Option<String>>)
Change header to specified option
sourcepub fn styles_mut(&mut self) -> &mut [String]
pub fn styles_mut(&mut self) -> &mut [String]
Get list of styles as a mutable slice
sourcepub fn regions_mut(&mut self) -> &mut [String]
pub fn regions_mut(&mut self) -> &mut [String]
Get list of regions as a mutable slice
sourcepub fn region_mut(&mut self, index: usize) -> Option<&mut String>
pub fn region_mut(&mut self, index: usize) -> Option<&mut String>
Get mutable region at index
Trait Implementations§
source§impl Clone for WebVttSubtitle
impl Clone for WebVttSubtitle
source§fn clone(&self) -> WebVttSubtitle
fn clone(&self) -> WebVttSubtitle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WebVttSubtitle
impl Debug for WebVttSubtitle
source§impl Default for WebVttSubtitle
impl Default for WebVttSubtitle
source§impl Display for WebVttSubtitle
impl Display for WebVttSubtitle
source§impl From<&AssSubtitle> for WebVttSubtitle
impl From<&AssSubtitle> for WebVttSubtitle
source§fn from(value: &AssSubtitle) -> Self
fn from(value: &AssSubtitle) -> Self
source§impl From<&SsaSubtitle> for WebVttSubtitle
impl From<&SsaSubtitle> for WebVttSubtitle
source§fn from(value: &SsaSubtitle) -> Self
fn from(value: &SsaSubtitle) -> Self
source§impl From<&SubRipSubtitle> for WebVttSubtitle
impl From<&SubRipSubtitle> for WebVttSubtitle
source§fn from(value: &SubRipSubtitle) -> Self
fn from(value: &SubRipSubtitle) -> Self
Convert a SubRip (.srt) subtitle to WebVTT format.
This sets the line number as the cue identifier.
The supported tags are <b>
, <i>
, and <u>
. Any other tags will be stripped from the text.
Bracket tags (of the form {b}
) will be converted to HTML tags (<b>
).
source§impl From<&TimedMicroDvdSubtitle> for WebVttSubtitle
impl From<&TimedMicroDvdSubtitle> for WebVttSubtitle
source§fn from(value: &TimedMicroDvdSubtitle) -> Self
fn from(value: &TimedMicroDvdSubtitle) -> Self
source§impl From<&WebVttSubtitle> for AssSubtitle
impl From<&WebVttSubtitle> for AssSubtitle
source§fn from(value: &WebVttSubtitle) -> Self
fn from(value: &WebVttSubtitle) -> Self
Convert WebVTT (.vtt) format subtitle to .ass format.
For each line, this will convert newlines into the appropriate representation,
and it will also convert the basic HTML formatting tags (<b>
, <i>
, and <u>
).
All other tags and styles are discarded.
source§impl From<&WebVttSubtitle> for SsaSubtitle
impl From<&WebVttSubtitle> for SsaSubtitle
source§fn from(value: &WebVttSubtitle) -> Self
fn from(value: &WebVttSubtitle) -> Self
Convert WebVTT (.vtt) format subtitle to .ssa format.
For each line, this will convert newlines into the appropriate representation,
and it will also convert the basic HTML formatting tags (<b>
, <i>
, and <u>
).
All other tags and styles are discarded.
source§impl From<&WebVttSubtitle> for SubRipSubtitle
impl From<&WebVttSubtitle> for SubRipSubtitle
source§fn from(value: &WebVttSubtitle) -> Self
fn from(value: &WebVttSubtitle) -> Self
Convert WebVTT (.vtt) subtitle to .srt format
Cue identifiers that are numbers will be treated as line numbers for the corresponding event in the .srt output.