input_with_interrupt

Function input_with_interrupt 

Source
pub fn input_with_interrupt<P: AsRef<Path> + ?Sized, F>(
    path: &P,
    closure: F,
) -> Result<Input, Error>
where F: FnMut() -> bool,
Expand description

Opens a media file for reading with interrupt callback.

Allows cancellation of long-running operations (network streams, slow I/O). The callback is called periodically; returning true aborts the operation.

§Parameters

  • path - Path to the media file
  • closure - Callback invoked periodically, return true to abort

§Example

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

let should_abort = Arc::new(AtomicBool::new(false));
let abort_flag = should_abort.clone();

let input = ffmpeg::format::input_with_interrupt(&"http://stream.example.com/live", move || {
    abort_flag.load(Ordering::Relaxed)
})?;