pub struct Context { /* private fields */ }Implementations§
Source§impl Context
impl Context
pub unsafe fn wrap(ptr: *mut AVCodecContext, owner: Option<Rc<dyn Any>>) -> Self
pub unsafe fn as_ptr(&self) -> *const AVCodecContext
pub unsafe fn as_mut_ptr(&mut self) -> *mut AVCodecContext
Source§impl Context
impl Context
pub fn new() -> Self
pub fn new_with_codec(codec: Codec) -> Self
Sourcepub fn from_parameters<P: Into<Parameters>>(
parameters: P,
) -> Result<Self, Error>
pub fn from_parameters<P: Into<Parameters>>( parameters: P, ) -> Result<Self, Error>
Examples found in repository?
examples/dump-frames.rs (line 21)
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}Sourcepub fn decoder(self) -> Decoder
pub fn decoder(self) -> Decoder
Examples found in repository?
examples/dump-frames.rs (line 22)
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}pub fn encoder(self) -> Encoder
pub fn codec(&self) -> Option<Codec>
pub fn medium(&self) -> Type
pub fn set_flags(&mut self, value: Flags)
pub fn id(&self) -> Id
pub fn compliance(&mut self, value: Compliance)
pub fn debug(&mut self, value: Debug)
pub fn set_threading(&mut self, config: Config)
pub fn threading(&self) -> Config
pub fn set_parameters<P: Into<Parameters>>( &mut self, parameters: P, ) -> Result<(), Error>
pub fn time_base(&self) -> Rational
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R)
pub fn frame_rate(&self) -> Rational
pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>)
Trait Implementations§
impl Send for Context
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl !Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl !UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more