pub struct SubtitleFilterBuilder { /* private fields */ }Expand description
Builder for SubtitleFilter; obtain one via SubtitleFilter::builder.
Implementations§
Source§impl SubtitleFilterBuilder
impl SubtitleFilterBuilder
Sourcepub fn ass_content(self, content: impl Into<String>) -> Self
pub fn ass_content(self, content: impl Into<String>) -> Self
Uses a complete ASS/SSA script held in memory (UTF-8) — no temp file.
Sourcepub fn fonts_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn fonts_dir(self, dir: impl Into<PathBuf>) -> Self
Extra directory scanned for font files (libass fontsdir), typically
where application-managed fonts are downloaded to.
Sourcepub fn default_font_file(self, font: impl Into<PathBuf>) -> Self
pub fn default_font_file(self, font: impl Into<PathBuf>) -> Self
Path to a concrete font file used as the default font. Combined with
FontProvider::None this pins rendering to exactly this file and
eliminates lookup races between a fonts dir and a family name.
Sourcepub fn default_family(self, family: impl Into<String>) -> Self
pub fn default_family(self, family: impl Into<String>) -> Self
Family name used when the script’s style does not resolve to a font.
Sourcepub fn font_provider(self, provider: FontProvider) -> Self
pub fn font_provider(self, provider: FontProvider) -> Self
See FontProvider; defaults to FontProvider::Autodetect.
Sourcepub fn force_style(self, style: impl Into<String>) -> Self
pub fn force_style(self, style: impl Into<String>) -> Self
Comma-separated Style.Field=Value overrides applied to the script’s
style definitions (same semantics as the FFmpeg subtitles filter’s
force_style). Inline override tags in dialogue lines still win.
Sourcepub fn original_size(self, width: u32, height: u32) -> Self
pub fn original_size(self, width: u32, height: u32) -> Self
Resolution the subtitles were authored against, used to compensate the
aspect ratio when the video was resized (FFmpeg original_size).
Sourcepub fn charenc(self, charenc: impl Into<String>) -> Self
pub fn charenc(self, charenc: impl Into<String>) -> Self
Character encoding of file/SRT sources (FFmpeg charenc; requires the
linked FFmpeg to support iconv). Not applicable to
Self::ass_content, which must already be UTF-8.
Sourcepub fn file(self, path: impl Into<PathBuf>) -> Self
pub fn file(self, path: impl Into<PathBuf>) -> Self
Burns subtitles from a file: .srt/.ass/.vtt, or any container holding
a text subtitle stream (same lavformat/lavcodec loader FFmpeg’s
subtitles filter uses, including container font attachments).
Sourcepub fn srt_content(self, content: impl Into<String>) -> Self
pub fn srt_content(self, content: impl Into<String>) -> Self
Uses SRT content held in memory (no temp file). Markup supported by
FFmpeg’s SRT decoder (<i>, <b>, <font color>, …) is honored.
Sourcepub fn stream_index(self, index: usize) -> Self
pub fn stream_index(self, index: usize) -> Self
Selects which subtitle stream to burn when the source has several
(0 = first subtitle stream), mirroring FFmpeg’s si option. Only
applies to Self::file sources.
Sourcepub fn wrap_unicode(self, enable: bool) -> Self
pub fn wrap_unicode(self, enable: bool) -> Self
Overrides the automatic Unicode line-wrapping rule (FFmpeg
wrap_unicode). Unset = FFmpeg’s auto behavior: enabled for decoded
non-ASS sources (SRT/VTT/…), disabled for native ASS scripts.
Requires a libass built with libunibreak; otherwise the request is
logged and ignored, like FFmpeg.
Sourcepub fn shaping(self, shaping: TextShaping) -> Self
pub fn shaping(self, shaping: TextShaping) -> Self
Text shaping engine; defaults to TextShaping::Auto (libass’s
default, complex shaping), mirroring the FFmpeg ass filter’s
shaping option.
Sourcepub fn font_scale(self, scale: f64) -> Self
pub fn font_scale(self, scale: f64) -> Self
Global multiplier applied to all font sizes (accessibility-style “bigger subtitles” without editing the script). 1.0 = script sizes.
Sourcepub fn line_position(self, percent: f64) -> Self
pub fn line_position(self, percent: f64) -> Self
Vertical position of regular (non-explicitly-positioned) events, in percent: 0.0 = author intent (default), 100.0 = top of the frame. Typical “raise subtitles” values are 5–20.
Sourcepub fn margins(self, top: i32, bottom: i32, left: i32, right: i32) -> Self
pub fn margins(self, top: i32, bottom: i32, left: i32, right: i32) -> Self
Distances (pixels) from the video rectangle to the frame edges, for
content with baked-in letterbox/pillarbox bars: subtitles are then
laid out relative to the picture area instead of the full frame.
Negative values express pan-and-scan. See also
Self::use_margins.
Sourcepub fn use_margins(self, enable: bool) -> Self
pub fn use_margins(self, enable: bool) -> Self
Allows regular events to be placed on the whole frame (e.g. onto
letterbox bars declared via Self::margins) instead of only
inside the video rectangle.
Sourcepub fn build(self) -> Result<SubtitleFilter, SubtitleError>
pub fn build(self) -> Result<SubtitleFilter, SubtitleError>
Validates the configuration, initializes libass, and loads the subtitle source. All failures surface here, never mid-pipeline.