Skip to main content

FfmpegDemuxer

Struct FfmpegDemuxer 

Source
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

Source

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.

Source

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.

Source

pub const fn input(&self) -> &Input

Borrows the wrapped ffmpeg::format::context::Input — for av_dump_format, container-level metadata, chapters, and anything else the portable track table has no seat for.

Trait Implementations§

Source§

impl Demuxer for FfmpegDemuxer

Source§

type Adapter = Ffmpeg

Backend-specific vocabulary.
Source§

type Buffer = FfmpegBuffer

Buffer type held by the packets this session produces.
Source§

type Error = DemuxError

Demuxer-specific error type.
Source§

fn tracks(&self) -> &[TrackInfo<Ffmpeg>]

Returns the container’s track table. Read more
Source§

fn take_tracks(&mut self) -> Vec<TrackInfo<Ffmpeg>>

Available on crate features alloc or std only.
Moves the whole track table out, once. Read more
Source§

fn next_packet( &mut self, ) -> Result<Option<DemuxedPacket<Ffmpeg, FfmpegBuffer>>, DemuxError>

Pulls the next packet in interleaved file order, or Ok(None) at end of file.
Source§

fn seek(&mut self, target: Timestamp) -> Result<(), DemuxError>

Seeks to target, landing on the nearest keyframe at or before it. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more