Struct ffmpeg_next::filter::context::Sink
source · pub struct Sink<'a> { /* private fields */ }
Implementations§
source§impl<'a> Sink<'a>
impl<'a> Sink<'a>
sourcepub fn frame(&mut self, frame: &mut Frame) -> Result<(), Error>
pub fn frame(&mut self, frame: &mut Frame) -> Result<(), Error>
Examples found in repository?
examples/transcode-audio.rs (line 167)
160 161 162 163 164 165 166 167 168 169 170 171 172 173
fn get_and_process_filtered_frames(&mut self, octx: &mut format::context::Output) {
let mut filtered = frame::Audio::empty();
while self
.filter
.get("out")
.unwrap()
.sink()
.frame(&mut filtered)
.is_ok()
{
self.send_frame_to_encoder(&filtered);
self.receive_and_process_encoded_packets(octx);
}
}
pub fn samples(&mut self, frame: &mut Frame, samples: usize) -> Result<(), Error>
sourcepub fn set_frame_size(&mut self, value: u32)
pub fn set_frame_size(&mut self, value: u32)
Examples found in repository?
examples/transcode-audio.rs (line 49)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
fn filter(
spec: &str,
decoder: &codec::decoder::Audio,
encoder: &codec::encoder::Audio,
) -> Result<filter::Graph, ffmpeg::Error> {
let mut filter = filter::Graph::new();
let args = format!(
"time_base={}:sample_rate={}:sample_fmt={}:channel_layout=0x{:x}",
decoder.time_base(),
decoder.rate(),
decoder.format().name(),
decoder.channel_layout().bits()
);
filter.add(&filter::find("abuffer").unwrap(), "in", &args)?;
filter.add(&filter::find("abuffersink").unwrap(), "out", "")?;
{
let mut out = filter.get("out").unwrap();
out.set_sample_format(encoder.format());
out.set_channel_layout(encoder.channel_layout());
out.set_sample_rate(encoder.rate());
}
filter.output("in", 0)?.input("out", 0)?.parse(spec)?;
filter.validate()?;
println!("{}", filter.dump());
if let Some(codec) = encoder.codec() {
if !codec
.capabilities()
.contains(ffmpeg::codec::capabilities::Capabilities::VARIABLE_FRAME_SIZE)
{
filter
.get("out")
.unwrap()
.sink()
.set_frame_size(encoder.frame_size());
}
}
Ok(filter)
}