Skip to main content

ProxyGenerator

Struct ProxyGenerator 

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

Generates a lower-resolution proxy file from an original media file.

Proxy files allow smooth real-time playback of high-resolution footage by substituting a lower-quality copy during editing. Uses ff_pipeline::Pipeline internally — no raw FFmpeg calls.

§Usage

let output = ProxyGenerator::new(Path::new("4k_clip.mp4"))?
    .resolution(ProxyResolution::Half)
    .output_dir(Path::new("/tmp/proxies"))
    .generate()?;

§Output path

{output_dir}/{stem}_proxy_{half|quarter|eighth}.mp4

Implementations§

Source§

impl ProxyGenerator

Source

pub fn new(input: &Path) -> Result<Self, PreviewError>

Open the input file and prepare for proxy generation.

Probes input to confirm it is a valid media file with a video stream.

§Errors

Returns PreviewError if the file cannot be probed.

Source

pub fn resolution(self, res: ProxyResolution) -> Self

Set the output resolution (default: ProxyResolution::Half).

Source

pub fn codec(self, codec: VideoCodec) -> Self

Set the output video codec (default: VideoCodec::H264).

Source

pub fn output_dir(self, dir: &Path) -> Self

Set the output directory (default: same directory as the input file).

Source

pub fn generate(self) -> Result<PathBuf, PreviewError>

Generate the proxy file synchronously.

Returns the path of the generated proxy file on success.

Dimensions are source ÷ resolution factor, rounded down to the nearest even number. Default quality: H.264 CRF 23, AAC audio.

§Errors

Returns PreviewError if probing, filtering, or encoding fails.

Source

pub fn generate_async(self) -> ProxyJob

Start proxy generation on a background thread and return immediately.

The returned ProxyJob lets you poll progress with ProxyJob::progress or block until completion with ProxyJob::wait.

Progress is tracked via ff-pipeline’s progress callback: each encoded frame updates an AtomicU32 (thousandths of completion, 0–1000). When the source container does not report a total frame count, progress stays at 0.0 throughout the run.

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