pub struct Mp4VideoReader { /* private fields */ }Expand description
Reads H.264-encoded MP4 video files and decodes frames to RGB8.
Combines the MP4 box parser, Annex B NAL extraction, and H.264 decoder into a single end-to-end reader.
ⓘ
let mut reader = Mp4VideoReader::open("input.mp4")?;
while let Some(frame) = reader.next_frame()? {
// frame.rgb8_data is Vec<u8>, frame.width / frame.height
}Implementations§
Source§impl Mp4VideoReader
impl Mp4VideoReader
Sourcepub fn open(path: &Path) -> Result<Self, VideoError>
pub fn open(path: &Path) -> Result<Self, VideoError>
Open an MP4 file containing H.264 video.
Reads the entire file, parses MP4 boxes to find the mdat box,
and extracts NAL units from the raw data.
Sourcepub fn next_frame(&mut self) -> Result<Option<DecodedFrame>, VideoError>
pub fn next_frame(&mut self) -> Result<Option<DecodedFrame>, VideoError>
Decode the next frame. Returns None when all NAL units are consumed.
Sourcepub fn seek_start(&mut self)
pub fn seek_start(&mut self)
Reset to the beginning (re-decode from first NAL).
Auto Trait Implementations§
impl Freeze for Mp4VideoReader
impl RefUnwindSafe for Mp4VideoReader
impl Send for Mp4VideoReader
impl Sync for Mp4VideoReader
impl Unpin for Mp4VideoReader
impl UnsafeUnpin for Mp4VideoReader
impl UnwindSafe for Mp4VideoReader
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
Mutably borrows from an owned value. Read more
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>
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 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>
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