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
impl ProxyGenerator
Sourcepub fn new(input: &Path) -> Result<Self, PreviewError>
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.
Sourcepub fn resolution(self, res: ProxyResolution) -> Self
pub fn resolution(self, res: ProxyResolution) -> Self
Set the output resolution (default: ProxyResolution::Half).
Sourcepub fn codec(self, codec: VideoCodec) -> Self
pub fn codec(self, codec: VideoCodec) -> Self
Set the output video codec (default: VideoCodec::H264).
Sourcepub fn output_dir(self, dir: &Path) -> Self
pub fn output_dir(self, dir: &Path) -> Self
Set the output directory (default: same directory as the input file).
Sourcepub fn generate(self) -> Result<PathBuf, PreviewError>
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.
Sourcepub fn generate_async(self) -> ProxyJob
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.