pub struct SwVideoCompositor { /* private fields */ }Expand description
Composites the latest frames from any number of independent input pipelines into one fixed-rate opaque BGRA video stream.
Like crate::elements::AudioMixer, this is a SourceElement, not
a conventional one-input filter: upstream pipelines terminate at the
sinks returned by SwVideoCompositorHandle::add_source, while this
element’s own pipeline drives output on its independent clock. Input
frame PTS values therefore do not become output PTS; output advances by
one tick in SwVideoCompositor::time_base for every composed frame.
Implementations§
Source§impl SwVideoCompositor
impl SwVideoCompositor
Sourcepub fn new(
name: impl Into<String>,
options: VideoCompositorOptions,
) -> Result<(Self, SwVideoCompositorHandle), SwVideoCompositorError>
pub fn new( name: impl Into<String>, options: VideoCompositorOptions, ) -> Result<(Self, SwVideoCompositorHandle), SwVideoCompositorError>
Creates a compositor and a weak runtime handle for registering inputs.
Sourcepub fn format(&self) -> Pixel
pub fn format(&self) -> Pixel
Returns the fixed output pixel format, ffmpeg::format::Pixel::BGRA.
Sourcepub fn frame_rate(&self) -> Rational
pub fn frame_rate(&self) -> Rational
The output frame rate, which is what construction was given unless
SwVideoCompositorHandle::set_frame_rate has changed it since.
Sourcepub fn time_base(&self) -> Rational
pub fn time_base(&self) -> Rational
The reciprocal of Self::frame_rate, used as output PTS units — and
so a value that moves with it.
Trait Implementations§
Source§impl Element for SwVideoCompositor
impl Element for SwVideoCompositor
Source§fn name(&self) -> Arc<str> ⓘ
fn name(&self) -> Arc<str> ⓘ
crate::bus::BusEvent stores names as
Arc<str> for exactly this reason: a hot path like
crate::queue::Queue posting BusEvent::Dropped once per
overflowed buffer shouldn’t pay for a fresh heap allocation every
time it wants to report which element it is.Source§fn element_type(&self) -> ElementType
fn element_type(&self) -> ElementType
ElementType.Source§fn pp_log(&self) -> &PpLog
fn pp_log(&self) -> &PpLog
crate::bus::Bus::post — same
id/name as Element::name, just already wrapped as the
crate::pp_log::PpLog its pp_info!/pp_warn!/pp_error! macros need. A
stored private field, not built fresh per call, for the same reason
name() returns a cheap Arc<str> clone instead of a fresh String
— see its own docs.Source§fn pp_log_mut(&mut self) -> &mut PpLog
fn pp_log_mut(&mut self) -> &mut PpLog
Element::pp_log reads — used by
crate::pipeline::ChainBuilder to stamp the owning
crate::pipeline::Pipeline’s id onto every element that
passes through it, via element_pp_log. Not meant to be called
from anywhere else.Source§fn graph_id(&self) -> Option<ElementId>
fn graph_id(&self) -> Option<ElementId>
ChainBuilder and keep the default None implementation.Source§fn attach_context(&mut self, _context: &Arc<Context>)
fn attach_context(&mut self, _context: &Arc<Context>)
Element::pp_log_mut hands it the pipeline’s
identity: the clock, the playback clock and the bus are the
pipeline’s to give, not the caller’s to choose. Read moreimpl Send for SwVideoCompositor
Source§impl Source for SwVideoCompositor
impl Source for SwVideoCompositor
Source§impl SourceElement for SwVideoCompositor
impl SourceElement for SwVideoCompositor
Source§fn is_live(&self) -> bool
fn is_live(&self) -> bool
Source§fn is_seekable(&self) -> bool
fn is_seekable(&self) -> bool
Self::seek. Read moreSource§fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
Eos (normal completion),
crate::pipeline::Pipeline::finish, or Stop (see
ControlMsg::Stop) — call crate::control::drain_control
once per loop iteration to make control responsive between
blocking reads. Read moreSource§fn seek(&mut self, _target: Duration) -> Result<Duration>
fn seek(&mut self, _target: Duration) -> Result<Duration>
target, an absolute position from the
start of the media (e.g. av_seek_frame for
crate::elements::FileDemuxer). Called by
crate::control::drain_control as part of handling
ControlMsg::Seek, before that message is forwarded to the
source’s own pads — so whatever’s read next comes from the new
position by the time downstream elements receive the new timeline
announcement. Buffered and stateful old-timeline data is discarded by
the preceding ControlMsg::Flush. Read moreSource§fn on_control(&mut self, _msg: &ControlMsg)
fn on_control(&mut self, _msg: &ControlMsg)
Self::seek gets, and for the same
reason: whatever this source holds must already reflect the message by
the time downstream elements see it. Read more