pub struct FfmpegDemuxer { /* private fields */ }Expand description
mediadecode::demuxer::Demuxer impl wrapping ffmpeg::format::context::Input.
Construction is deliberately not on the trait — see Self::open
and Self::open_reader.
Implementations§
Source§impl FfmpegDemuxer
impl FfmpegDemuxer
Sourcepub fn open<P: AsRef<Path> + ?Sized>(path: &P) -> Result<Self, DemuxError>
pub fn open<P: AsRef<Path> + ?Sized>(path: &P) -> Result<Self, DemuxError>
Opens a container from a filesystem path.
Runs avformat_open_input followed by
avformat_find_stream_info, then builds the track table and
captures every attachment payload.
Call ffmpeg_next::init once before the first open if you want
FFmpeg’s logging and network protocols configured; probing a local
container does not require it.
Sourcepub fn open_reader<R: Read + Seek + Send + 'static>(
reader: R,
filename: Option<&str>,
) -> Result<Self, DemuxError>
pub fn open_reader<R: Read + Seek + Send + 'static>( reader: R, filename: Option<&str>, ) -> Result<Self, DemuxError>
Opens a container from any Read + Seek byte source, through a
custom AVIOContext.
Seek is mandatory and not negotiable: MP4 files routinely put
moov at the end, so a reader that cannot go backwards cannot be
probed at all — and the seek law on the face would be
unimplementable.
filename is a probe hint, not a path: libavformat uses its
extension to break ties between formats whose byte signatures are
ambiguous. Pass None when there is nothing to hint with.
§A panicking reader
libavformat drives the reader from extern "C" callbacks, where a
panic would abort the process rather than unwind. Every call into
reader therefore runs under catch_unwind: a panic becomes an
I/O error for libavformat and surfaces here — or from the next
next_packet / seek —
as DemuxError::ReaderPanic, carrying the panic’s message. The
session is terminal from that point: the AVIOContext’s error
state is sticky and the reader’s own state is unknown.
Trait Implementations§
Source§impl Demuxer for FfmpegDemuxer
impl Demuxer for FfmpegDemuxer
Source§type Buffer = FfmpegBuffer
type Buffer = FfmpegBuffer
Source§type Error = DemuxError
type Error = DemuxError
Source§fn take_tracks(&mut self) -> Vec<TrackInfo<Ffmpeg>>
fn take_tracks(&mut self) -> Vec<TrackInfo<Ffmpeg>>
alloc or std only.Source§fn next_packet(
&mut self,
) -> Result<Option<DemuxedPacket<Ffmpeg, FfmpegBuffer>>, DemuxError>
fn next_packet( &mut self, ) -> Result<Option<DemuxedPacket<Ffmpeg, FfmpegBuffer>>, DemuxError>
Ok(None) at
end of file.