Skip to main content

VideoReader

Struct VideoReader 

Source
pub struct VideoReader { /* private fields */ }
Available on crate feature decode only.
Expand description

A video file, read a picture at a time in display order. See the module docs.

Implementations§

Source§

impl VideoReader

Source

pub fn open(data: Vec<u8>) -> Result<Self, String>

Open a file held in memory, decoding in hardware where this build and machine can. Fails if the container or codec is not one this crate reads, or the stream’s configuration does not parse.

Source

pub fn open_file(path: impl AsRef<Path>) -> Result<Self, String>

Open the file at path, mapped rather than read: the operating system pages in what decoding touches as it touches it, so a film of many gigabytes starts at once and is never all in memory. See Bytes::map.

Source

pub fn open_shared(data: impl Into<Bytes>) -> Result<Self, String>

As open, holding the bytes shared rather than owned: for a caller that reads them again, as a player decoding the soundtrack does, without a second copy of the file.

Source

pub fn open_software(data: Vec<u8>) -> Result<Self, String>

As open, with the native decoders only.

Source

pub fn frame_pool(&self) -> FramePool

The pool the hardware decoders copy pictures into. Give a Picture::Packed’s buffers back here once it has been shown (recycle does, or keep this handle on another thread and call FramePool::give): a few buffers then serve the whole film, instead of a fresh allocation a picture, which at 8K costs more than the copy. Giving nothing back is fine, only slower.

Source

pub fn recycle(&self, picture: Picture)

Give a picture’s buffers back to frame_pool.

Source

pub fn backend(&self) -> Backend

Which decoder is doing the work.

Source

pub fn size(&self) -> (u32, u32)

The picture size the container states.

Source

pub fn duration(&self) -> f64

How long the clip runs, in seconds: from the first picture shown to the end of the last.

Source

pub fn frame_count(&self) -> usize

How many coded pictures the file holds.

Source

pub fn next_frame(&mut self) -> Result<Option<(f64, DecodedFrame)>, String>

The next picture in display order and when it shows, in seconds from the first; None at the end. A sample that fails to decode is skipped, as a player would, unless nothing has decoded at all.

Source

pub fn next_picture(&mut self) -> Result<Option<(f64, Picture)>, String>

next_frame, with the picture as the decoder left it: packed NV12 or P010 from a hardware decoder, which a GPU can convert without a pass over it on the CPU; planes otherwise.

Source

pub fn rewind(&mut self) -> Result<(), String>

Back to the first picture.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.