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?
3fn main() -> Result<(), Error> {
4 // We can directly specify the format to open a subtitle file
5 let vtt = WebVttSubtitle::from_path("/path/to/some.vtt")?;
6
7 // and then directly work with its data
8 println!("{}", vtt.header().cloned().unwrap_or_default());
9
10 // or we could use the more general interface to open (timed) subtitle files
11 let sub = TimedSubtitleFile::new("/path/to/file.srt")?;
12
13 // Move the underlying data out in order to access format-specific properties
14 // Note that if the format doesn't match, this will perform a conversion instead of just moving the data
15 let mut srt = SubRipSubtitle::from(sub);
16
17 // Now we can access format-specific methods like SubRipSubtitle::renumber()
18 srt.renumber();
19
20 // Access and modify events
21 for event in srt.events_mut() {
22 event.shift(600.into());
23 }
24
25 // Write the modified subtitle to file
26 srt.export("/path/to/output.srt")?;
27
28 Ok(())
29}
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.