pub struct DemuxInput { /* private fields */ }Expand description
A container opened for reading under an input policy: only the demuxers
it names, only the file protocol, and an interrupt callback the reader
binds to its own cancellation.
The format context is read through Deref, and moved only by the
methods here. FFmpeg holds a pointer to this input’s interrupt state,
which lives exactly as long as the input, so the context can never be
taken out of it and outlive that state:
let stolen = std::mem::replace(&mut *demux, other);
drop(demux);Implementations§
Source§impl DemuxInput
impl DemuxInput
Sourcepub fn interrupt_when(&self, check: impl Fn() -> bool + Send + Sync + 'static)
pub fn interrupt_when(&self, check: impl Fn() -> bool + Send + Sync + 'static)
Makes every FFmpeg call on this input that waits on I/O, from now
until the next call to this, stop with AVERROR_EXIT once check
returns true.
Sourcepub fn best_stream(
&self,
media_type: AVMediaType,
) -> Result<Option<usize>, RsmpegError>
pub fn best_stream( &self, media_type: AVMediaType, ) -> Result<Option<usize>, RsmpegError>
The stream of media_type a reader shows, by its AVStream index:
the one av_find_best_stream picks among those with a decoder, never
an attached picture (a song’s cover art is metadata, not its video).
When FFmpeg picks an attached picture, the first other stream of the
type that has a decoder is chosen, in stream order.
None when the input has no such stream, or none that this runtime
can decode: a stream without a decoder leaves the type unselected
rather than failing the input, whose other streams may decode.
§Errors
Any other av_find_best_stream failure.
Sourcepub fn read_packet(&mut self) -> Result<Option<AVPacket>, RsmpegError>
pub fn read_packet(&mut self) -> Result<Option<AVPacket>, RsmpegError>
The next packet in file order (av_read_frame), or None at the
end of the file.
§Errors
The FFmpeg read failure, or AVERROR_EXIT when the interrupt
check stopped it.
Sourcepub fn seek(
&mut self,
stream_index: i32,
timestamp: i64,
flags: i32,
) -> Result<(), RsmpegError>
pub fn seek( &mut self, stream_index: i32, timestamp: i64, flags: i32, ) -> Result<(), RsmpegError>
Seeks to the key frame at timestamp of stream_index
(av_seek_frame; -1 for AV_TIME_BASE units).
§Errors
The FFmpeg seek failure, or AVERROR_EXIT when the interrupt check
stopped it.
Sourcepub fn discard_all_but(&mut self, index: usize)
pub fn discard_all_but(&mut self, index: usize)
Has the demuxer skip every stream but index: a reader of one stream
then neither reads nor copies the others’ packets (AVDISCARD_ALL),
which demuxers such as mov do not even fetch from the file.
Sourcepub fn keep_only(&mut self, kept: &[usize])
pub fn keep_only(&mut self, kept: &[usize])
Self::discard_all_but for a reader of the streams kept.
Methods from Deref<Target = AVFormatContextInput>§
pub fn as_ptr(&self) -> *const AVFormatContext
Sourcepub fn find_best_stream(
&self,
media_type: i32,
) -> Result<Option<(usize, AVCodecRef<'static>)>, RsmpegError>
pub fn find_best_stream( &self, media_type: i32, ) -> Result<Option<(usize, AVCodecRef<'static>)>, RsmpegError>
Return the stream index and stream decoder if there is any “best” stream. “best” means the most likely what the user wants.
Sourcepub fn streams(&'stream self) -> &'stream [AVStreamRef<'stream>]
pub fn streams(&'stream self) -> &'stream [AVStreamRef<'stream>]
Return slice of AVStreamRef.
Sourcepub fn iformat(&'stream self) -> AVInputFormatRef<'stream>
pub fn iformat(&'stream self) -> AVInputFormatRef<'stream>
Get AVInputFormatRef in the AVFormatContextInput.
Sourcepub fn metadata(&'stream self) -> Option<AVDictionaryRef<'stream>>
pub fn metadata(&'stream self) -> Option<AVDictionaryRef<'stream>>
Get metadata of the ffi::AVFormatContext in crate::avutil::AVDictionary.
demuxing: set by libavformat in avformat_open_input()
muxing: may be set by the caller before avformat_write_header()