Skip to main content

Audio

Struct Audio 

Source
pub struct Audio(pub Opened);

Tuple Fields§

§0: Opened

Implementations§

Source§

impl Audio

Source

pub fn rate(&self) -> u32

Source

pub fn channels(&self) -> u16

Source

pub fn format(&self) -> Sample

Source

pub fn request_format(&mut self, value: Sample)

Source

pub fn frames(&self) -> usize

Source

pub fn align(&self) -> usize

Source

pub fn channel_layout(&self) -> ChannelLayout

Source

pub fn set_channel_layout(&mut self, value: ChannelLayout)

Source

pub fn request_channel_layout(&mut self, value: ChannelLayout)

Source

pub fn audio_service(&mut self) -> AudioService

Source

pub fn max_bit_rate(&self) -> usize

Source

pub fn frame_size(&self) -> u32

Source§

impl Audio

Source

pub fn resampler( &self, format: Sample, channel_layout: ChannelLayout, rate: u32, ) -> Result<Context, Error>

Methods from Deref<Target = Opened>§

Source

pub fn send_packet<P: Ref>(&mut self, packet: &P) -> Result<(), Error>

Examples found in repository?
examples/dump-frames.rs (line 50)
11fn main() -> Result<(), ffmpeg::Error> {
12    ffmpeg::init().unwrap();
13
14    if let Ok(mut ictx) = input(&env::args().nth(1).expect("Cannot open file.")) {
15        let input = ictx
16            .streams()
17            .best(Type::Video)
18            .ok_or(ffmpeg::Error::StreamNotFound)?;
19        let video_stream_index = input.index();
20
21        let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
22        let mut decoder = context_decoder.decoder().video()?;
23
24        let mut scaler = Context::get(
25            decoder.format(),
26            decoder.width(),
27            decoder.height(),
28            Pixel::RGB24,
29            decoder.width(),
30            decoder.height(),
31            Flags::BILINEAR,
32        )?;
33
34        let mut frame_index = 0;
35
36        let mut receive_and_process_decoded_frames =
37            |decoder: &mut ffmpeg::decoder::Video| -> Result<(), ffmpeg::Error> {
38                let mut decoded = Video::empty();
39                while decoder.receive_frame(&mut decoded).is_ok() {
40                    let mut rgb_frame = Video::empty();
41                    scaler.run(&decoded, &mut rgb_frame)?;
42                    save_file(&rgb_frame, frame_index).unwrap();
43                    frame_index += 1;
44                }
45                Ok(())
46            };
47
48        for (stream, packet) in ictx.packets() {
49            if stream.index() == video_stream_index {
50                decoder.send_packet(&packet)?;
51                receive_and_process_decoded_frames(&mut decoder)?;
52            }
53        }
54        decoder.send_eof()?;
55        receive_and_process_decoded_frames(&mut decoder)?;
56    }
57
58    Ok(())
59}
Source

pub fn send_eof(&mut self) -> Result<(), Error>

Sends a NULL packet to the decoder to signal end of stream and enter draining mode.

Examples found in repository?
examples/dump-frames.rs (line 54)
11fn main() -> Result<(), ffmpeg::Error> {
12    ffmpeg::init().unwrap();
13
14    if let Ok(mut ictx) = input(&env::args().nth(1).expect("Cannot open file.")) {
15        let input = ictx
16            .streams()
17            .best(Type::Video)
18            .ok_or(ffmpeg::Error::StreamNotFound)?;
19        let video_stream_index = input.index();
20
21        let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
22        let mut decoder = context_decoder.decoder().video()?;
23
24        let mut scaler = Context::get(
25            decoder.format(),
26            decoder.width(),
27            decoder.height(),
28            Pixel::RGB24,
29            decoder.width(),
30            decoder.height(),
31            Flags::BILINEAR,
32        )?;
33
34        let mut frame_index = 0;
35
36        let mut receive_and_process_decoded_frames =
37            |decoder: &mut ffmpeg::decoder::Video| -> Result<(), ffmpeg::Error> {
38                let mut decoded = Video::empty();
39                while decoder.receive_frame(&mut decoded).is_ok() {
40                    let mut rgb_frame = Video::empty();
41                    scaler.run(&decoded, &mut rgb_frame)?;
42                    save_file(&rgb_frame, frame_index).unwrap();
43                    frame_index += 1;
44                }
45                Ok(())
46            };
47
48        for (stream, packet) in ictx.packets() {
49            if stream.index() == video_stream_index {
50                decoder.send_packet(&packet)?;
51                receive_and_process_decoded_frames(&mut decoder)?;
52            }
53        }
54        decoder.send_eof()?;
55        receive_and_process_decoded_frames(&mut decoder)?;
56    }
57
58    Ok(())
59}
Source

pub fn receive_frame(&mut self, frame: &mut Frame) -> Result<(), Error>

Examples found in repository?
examples/dump-frames.rs (line 39)
11fn main() -> Result<(), ffmpeg::Error> {
12    ffmpeg::init().unwrap();
13
14    if let Ok(mut ictx) = input(&env::args().nth(1).expect("Cannot open file.")) {
15        let input = ictx
16            .streams()
17            .best(Type::Video)
18            .ok_or(ffmpeg::Error::StreamNotFound)?;
19        let video_stream_index = input.index();
20
21        let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
22        let mut decoder = context_decoder.decoder().video()?;
23
24        let mut scaler = Context::get(
25            decoder.format(),
26            decoder.width(),
27            decoder.height(),
28            Pixel::RGB24,
29            decoder.width(),
30            decoder.height(),
31            Flags::BILINEAR,
32        )?;
33
34        let mut frame_index = 0;
35
36        let mut receive_and_process_decoded_frames =
37            |decoder: &mut ffmpeg::decoder::Video| -> Result<(), ffmpeg::Error> {
38                let mut decoded = Video::empty();
39                while decoder.receive_frame(&mut decoded).is_ok() {
40                    let mut rgb_frame = Video::empty();
41                    scaler.run(&decoded, &mut rgb_frame)?;
42                    save_file(&rgb_frame, frame_index).unwrap();
43                    frame_index += 1;
44                }
45                Ok(())
46            };
47
48        for (stream, packet) in ictx.packets() {
49            if stream.index() == video_stream_index {
50                decoder.send_packet(&packet)?;
51                receive_and_process_decoded_frames(&mut decoder)?;
52            }
53        }
54        decoder.send_eof()?;
55        receive_and_process_decoded_frames(&mut decoder)?;
56    }
57
58    Ok(())
59}
Source

pub fn bit_rate(&self) -> usize

Source

pub fn delay(&self) -> usize

Source

pub fn profile(&self) -> Profile

Source

pub fn frame_rate(&self) -> Option<Rational>

Source

pub fn flush(&mut self)

Methods from Deref<Target = Decoder>§

Source

pub fn conceal(&mut self, value: Conceal)

Source

pub fn check(&mut self, value: Check)

Source

pub fn skip_loop_filter(&mut self, value: Discard)

Source

pub fn skip_idct(&mut self, value: Discard)

Source

pub fn skip_frame(&mut self, value: Discard)

Source

pub fn packet_time_base(&self) -> Rational

Source

pub fn set_packet_time_base<R: Into<Rational>>(&mut self, value: R)

Methods from Deref<Target = Context>§

Source

pub unsafe fn as_ptr(&self) -> *const AVCodecContext

Source

pub unsafe fn as_mut_ptr(&mut self) -> *mut AVCodecContext

Source

pub fn codec(&self) -> Option<Codec>

Source

pub fn medium(&self) -> Type

Source

pub fn set_flags(&mut self, value: Flags)

Source

pub fn id(&self) -> Id

Source

pub fn compliance(&mut self, value: Compliance)

Source

pub fn debug(&mut self, value: Debug)

Source

pub fn set_threading(&mut self, config: Config)

Source

pub fn threading(&self) -> Config

Source

pub fn set_parameters<P: Into<Parameters>>( &mut self, parameters: P, ) -> Result<(), Error>

Source

pub fn time_base(&self) -> Rational

Source

pub fn set_time_base<R: Into<Rational>>(&mut self, value: R)

Source

pub fn frame_rate(&self) -> Rational

Source

pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>)

Trait Implementations§

Source§

impl AsMut<Context> for Audio

Source§

fn as_mut(&mut self) -> &mut Context

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Context> for Audio

Source§

fn as_ref(&self) -> &Context

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Deref for Audio

Source§

type Target = Opened

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Self as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for Audio

Source§

fn deref_mut(&mut self) -> &mut <Self as Deref>::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl Freeze for Audio

§

impl !RefUnwindSafe for Audio

§

impl Send for Audio

§

impl !Sync for Audio

§

impl Unpin for Audio

§

impl UnsafeUnpin for Audio

§

impl !UnwindSafe for Audio

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.