Skip to main content

SubtitleFilterBuilder

Struct SubtitleFilterBuilder 

Source
pub struct SubtitleFilterBuilder { /* private fields */ }
Expand description

Builder for SubtitleFilter; obtain one via SubtitleFilter::builder.

Implementations§

Source§

impl SubtitleFilterBuilder

Source

pub fn ass_content(self, content: impl Into<String>) -> Self

Uses a complete ASS/SSA script held in memory (UTF-8) — no temp file.

Source

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.

Source

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.

Source

pub fn default_family(self, family: impl Into<String>) -> Self

Family name used when the script’s style does not resolve to a font.

Source

pub fn font_provider(self, provider: FontProvider) -> Self

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn build(self) -> Result<SubtitleFilter, SubtitleError>

Validates the configuration, initializes libass, and loads the subtitle source. All failures surface here, never mid-pipeline.

Trait Implementations§

Source§

impl Debug for SubtitleFilterBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SubtitleFilterBuilder

Source§

fn default() -> SubtitleFilterBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,