pub struct VideoReader<B: Backend> { /* private fields */ }Expand description
A high-level video reader that loads frames into memory.
Supports animated images (GIF, APNG), image sequences, and basic container formats. All frames are cached for fast random access.
Implementations§
Source§impl<B: Backend> VideoReader<B>
impl<B: Backend> VideoReader<B>
Sourcepub fn open(path: impl AsRef<Path>, options: &VideoOpenOptions) -> Result<Self>
pub fn open(path: impl AsRef<Path>, options: &VideoOpenOptions) -> Result<Self>
Opens a video file and loads all frames into memory.
Sourcepub fn from_frames(frames: Vec<Frame<B>>, metadata: VideoMetadata) -> Self
pub fn from_frames(frames: Vec<Frame<B>>, metadata: VideoMetadata) -> Self
Creates a reader from pre-loaded frames and metadata.
Useful for in-memory video processing pipelines where frames are generated or loaded programmatically.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Returns the total number of loaded frames.
Sourcepub fn metadata(&self) -> &VideoMetadata
pub fn metadata(&self) -> &VideoMetadata
Returns video metadata.
Sourcepub fn source_path(&self) -> Option<&Path>
pub fn source_path(&self) -> Option<&Path>
Returns the source file path.
Sourcepub fn iter(&self) -> FrameIterator<B> ⓘ
pub fn iter(&self) -> FrameIterator<B> ⓘ
Returns a frame iterator for sequential access.
Sourcepub fn loop_iter(&self) -> FrameIterator<B> ⓘ
pub fn loop_iter(&self) -> FrameIterator<B> ⓘ
Returns a looping frame iterator.
Sourcepub fn get_range(&self, start: usize, end: usize) -> Result<&[Frame<B>]>
pub fn get_range(&self, start: usize, end: usize) -> Result<&[Frame<B>]>
Gets frames in a range.
Sourcepub fn seek_to_time(&self, time: Duration) -> Result<&Frame<B>>
pub fn seek_to_time(&self, time: Duration) -> Result<&Frame<B>>
Seeks to a specific timestamp and returns the frame.
Sourcepub fn to_batch_tensor(&self) -> Result<Tensor<B, 4>>
pub fn to_batch_tensor(&self) -> Result<Tensor<B, 4>>
Converts frames to a 4D tensor [B, C, H, W] (batch dimension).
Sourcepub fn frame_differences(&self) -> Result<Vec<Tensor<B, 3>>>
pub fn frame_differences(&self) -> Result<Vec<Tensor<B, 3>>>
Computes per-frame differences (absolute difference between consecutive frames).
Sourcepub fn motion_magnitudes(&self) -> Result<Vec<f32>>
pub fn motion_magnitudes(&self) -> Result<Vec<f32>>
Computes optical flow magnitude (sum of absolute differences) between consecutive frames.
Auto Trait Implementations§
impl<B> Freeze for VideoReader<B>
impl<B> RefUnwindSafe for VideoReader<B>where
<B as BackendTypes>::FloatTensorPrimitive: RefUnwindSafe,
<B as BackendTypes>::QuantizedTensorPrimitive: RefUnwindSafe,
impl<B> Send for VideoReader<B>
impl<B> Sync for VideoReader<B>
impl<B> Unpin for VideoReader<B>where
<B as BackendTypes>::FloatTensorPrimitive: Unpin,
<B as BackendTypes>::QuantizedTensorPrimitive: Unpin,
impl<B> UnsafeUnpin for VideoReader<B>
impl<B> UnwindSafe for VideoReader<B>where
<B as BackendTypes>::FloatTensorPrimitive: UnwindSafe,
<B as BackendTypes>::QuantizedTensorPrimitive: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more