pub struct Reader {
pub source: Location,
pub input: Input,
}
Expand description
Video reader that can read from files.
Fields§
§source: Location
§input: Input
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn new(source: impl Into<Location>) -> Result<Self, Error>
pub fn new(source: impl Into<Location>) -> Result<Self, Error>
Create a new video file reader on a given source (path, URL, etc.).
§Arguments
source
- Source to read from.
Sourcepub fn read(&mut self, stream_index: usize) -> Result<Packet, Error>
pub fn read(&mut self, stream_index: usize) -> Result<Packet, Error>
Read a single packet from the source video file.
§Arguments
stream_index
- Index of stream to read from.
§Example
Read a single packet:
ⓘ
let mut reader = Reader::new(Path::new("my_video.mp4")).unwrap();
let stream = reader.best_video_stream_index().unwrap();
let mut packet = reader.read(stream).unwrap();
Sourcepub fn stream_info(&self, stream_index: usize) -> Result<StreamInfo, Error>
pub fn stream_info(&self, stream_index: usize) -> Result<StreamInfo, Error>
Retrieve stream information for a stream. Stream information can be used to set up a corresponding stream for transmuxing or transcoding.
§Arguments
stream_index
- Index of stream to produce information for.
Sourcepub fn seek(&mut self, timestamp_milliseconds: i64) -> Result<(), Error>
pub fn seek(&mut self, timestamp_milliseconds: i64) -> Result<(), Error>
Seek in reader. This will change the reader head so that it points to a location within one second of the target timestamp or it will return an error.
§Arguments
timestamp_milliseconds
- Number of millisecond from start of video to seek to.
Sourcepub fn seek_to_frame(&mut self, frame_number: i64) -> Result<(), Error>
pub fn seek_to_frame(&mut self, frame_number: i64) -> Result<(), Error>
Seek to a specific frame in the video stream.
§Arguments
frame_number
- The frame number to seek to.
Sourcepub fn seek_to_start(&mut self) -> Result<(), Error>
pub fn seek_to_start(&mut self) -> Result<(), Error>
Seek to start of reader. This function performs best effort seeking to the start of the file.
Sourcepub fn best_video_stream_index(&self) -> Result<usize, Error>
pub fn best_video_stream_index(&self) -> Result<usize, Error>
Find the best video stream and return the index.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Reader
impl RefUnwindSafe for Reader
impl Unpin for Reader
impl UnwindSafe for Reader
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