Skip to main content

ExportPreset

Struct ExportPreset 

Source
pub struct ExportPreset {
    pub name: String,
    pub video: Option<VideoEncoderConfig>,
    pub audio: AudioEncoderConfig,
}
Expand description

A named export preset combining video and audio encoder configuration.

Create a predefined preset with ExportPreset::youtube_1080p() etc., or build a custom one as a struct literal. Call validate() before encoding to catch platform-constraint violations early.

video: None indicates an audio-only preset (e.g. podcast_mono).

§Examples

use ff_encode::{ExportPreset, VideoEncoder};

let preset = ExportPreset::youtube_1080p();
preset.validate()?;

let mut encoder = preset
    .apply_video(VideoEncoder::create("output.mp4"))
    .build()?;

Fields§

§name: String

Human-readable name (e.g. "youtube_1080p").

§video: Option<VideoEncoderConfig>

Video encoder configuration. None = audio-only preset.

§audio: AudioEncoderConfig

Audio encoder configuration.

Implementations§

Source§

impl ExportPreset

Source

pub fn youtube_1080p() -> Self

YouTube 1080p preset: H.264, CRF 18, 1920×1080, 30 fps, AAC 192 kbps.

Source

pub fn youtube_4k() -> Self

YouTube 4K preset: H.265, CRF 20, 3840×2160, 30 fps, AAC 256 kbps.

Source

pub fn twitter() -> Self

Twitter/X preset: H.264, CRF 23, 1280×720, 30 fps, AAC 128 kbps.

Source

pub fn instagram_square() -> Self

Instagram Square preset: H.264, CRF 23, 1080×1080, 30 fps, AAC 128 kbps.

Source

pub fn instagram_reels() -> Self

Instagram Reels preset: H.264, CRF 23, 1080×1920, 30 fps, AAC 128 kbps.

Source

pub fn bluray_1080p() -> Self

Blu-ray 1080p preset: H.264, CRF 18, 1920×1080, 24 fps, AC-3 384 kbps.

Source

pub fn podcast_mono() -> Self

Podcast mono preset (audio-only): AAC 128 kbps, mono, 48 kHz.

Source

pub fn lossless_rgb() -> Self

Lossless archive preset: FFV1 video (source resolution), FLAC audio.

Source

pub fn web_h264() -> Self

Web H.264 preset (VP9): VP9, CRF 33, 1280×720, 30 fps, Opus 128 kbps.

Source

pub fn validate(&self) -> Result<(), EncodeError>

Validates this preset against platform-specific constraints.

Call this before passing the preset to apply_video or apply_audio to surface constraint violations before encoding begins.

§Errors

Returns EncodeError::PresetConstraintViolation when a platform rule is violated (e.g. fps > 60 on a YouTube preset, or wrong aspect ratio on an Instagram preset).

Source

pub fn apply_video(&self, builder: VideoEncoderBuilder) -> VideoEncoderBuilder

Applies the video configuration to a VideoEncoderBuilder.

Sets the codec and bitrate mode unconditionally. Resolution and frame rate are only applied when all three (width, height, fps) are Some. Pixel format and per-codec options are applied when present.

Returns builder unchanged when video is None (audio-only preset).

Source

pub fn apply_audio(&self, builder: VideoEncoderBuilder) -> VideoEncoderBuilder

Applies the audio configuration to a VideoEncoderBuilder.

Sets sample rate, channel count, codec, and bitrate.

Trait Implementations§

Source§

impl Clone for ExportPreset

Source§

fn clone(&self) -> ExportPreset

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExportPreset

Source§

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

Formats the value using the given formatter. 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.