pub struct VideoReader { /* private fields */ }decode only.Expand description
A video file, read a picture at a time in display order. See the module docs.
Implementations§
Source§impl VideoReader
impl VideoReader
Sourcepub fn open(data: Vec<u8>) -> Result<Self, String>
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.
Sourcepub fn open_file(path: impl AsRef<Path>) -> Result<Self, String>
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.
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.
Sourcepub fn open_software(data: Vec<u8>) -> Result<Self, String>
pub fn open_software(data: Vec<u8>) -> Result<Self, String>
As open, with the native decoders only.
Sourcepub fn frame_pool(&self) -> FramePool
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.
Sourcepub fn recycle(&self, picture: Picture)
pub fn recycle(&self, picture: Picture)
Give a picture’s buffers back to frame_pool.
Sourcepub fn duration(&self) -> f64
pub fn duration(&self) -> f64
How long the clip runs, in seconds: from the first picture shown to the end of the last.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
How many coded pictures the file holds.
Sourcepub fn next_frame(&mut self) -> Result<Option<(f64, DecodedFrame)>, String>
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.
Sourcepub fn next_picture(&mut self) -> Result<Option<(f64, Picture)>, String>
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.
Auto Trait Implementations§
impl !RefUnwindSafe for VideoReader
impl !Send for VideoReader
impl !Sync for VideoReader
impl !UnwindSafe for VideoReader
impl Forget for VideoReader
impl Freeze for VideoReader
impl Unpin for VideoReader
impl UnsafeUnpin for VideoReader
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
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