pub struct Video(_);
Implementations§
source§impl Video
impl Video
sourcepub fn empty() -> Self
pub fn empty() -> Self
Examples found in repository?
examples/transcode-x264.rs (line 101)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
fn receive_and_process_decoded_frames(
&mut self,
octx: &mut format::context::Output,
ost_time_base: Rational,
) {
let mut frame = frame::Video::empty();
while self.decoder.receive_frame(&mut frame).is_ok() {
self.frame_count += 1;
let timestamp = frame.timestamp();
self.log_progress(f64::from(
Rational(timestamp.unwrap_or(0) as i32, 1) * self.decoder.time_base(),
));
frame.set_pts(timestamp);
frame.set_kind(picture::Type::None);
self.send_frame_to_encoder(&frame);
self.receive_and_process_encoded_packets(octx, ost_time_base);
}
}
More examples
examples/dump-frames.rs (line 38)
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 55 56 57 58 59
fn main() -> Result<(), ffmpeg::Error> {
ffmpeg::init().unwrap();
if let Ok(mut ictx) = input(&env::args().nth(1).expect("Cannot open file.")) {
let input = ictx
.streams()
.best(Type::Video)
.ok_or(ffmpeg::Error::StreamNotFound)?;
let video_stream_index = input.index();
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
let mut decoder = context_decoder.decoder().video()?;
let mut scaler = Context::get(
decoder.format(),
decoder.width(),
decoder.height(),
Pixel::RGB24,
decoder.width(),
decoder.height(),
Flags::BILINEAR,
)?;
let mut frame_index = 0;
let mut receive_and_process_decoded_frames =
|decoder: &mut ffmpeg::decoder::Video| -> Result<(), ffmpeg::Error> {
let mut decoded = Video::empty();
while decoder.receive_frame(&mut decoded).is_ok() {
let mut rgb_frame = Video::empty();
scaler.run(&decoded, &mut rgb_frame)?;
save_file(&rgb_frame, frame_index).unwrap();
frame_index += 1;
}
Ok(())
};
for (stream, packet) in ictx.packets() {
if stream.index() == video_stream_index {
decoder.send_packet(&packet)?;
receive_and_process_decoded_frames(&mut decoder)?;
}
}
decoder.send_eof()?;
receive_and_process_decoded_frames(&mut decoder)?;
}
Ok(())
}
pub fn new(format: Pixel, width: u32, height: u32) -> Self
pub fn format(&self) -> Pixel
pub fn set_format(&mut self, value: Pixel)
pub fn kind(&self) -> Type
sourcepub fn set_kind(&mut self, value: Type)
pub fn set_kind(&mut self, value: Type)
Examples found in repository?
examples/transcode-x264.rs (line 109)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
fn receive_and_process_decoded_frames(
&mut self,
octx: &mut format::context::Output,
ost_time_base: Rational,
) {
let mut frame = frame::Video::empty();
while self.decoder.receive_frame(&mut frame).is_ok() {
self.frame_count += 1;
let timestamp = frame.timestamp();
self.log_progress(f64::from(
Rational(timestamp.unwrap_or(0) as i32, 1) * self.decoder.time_base(),
));
frame.set_pts(timestamp);
frame.set_kind(picture::Type::None);
self.send_frame_to_encoder(&frame);
self.receive_and_process_encoded_packets(octx, ost_time_base);
}
}
pub fn is_interlaced(&self) -> bool
pub fn is_top_first(&self) -> bool
pub fn has_palette_changed(&self) -> bool
pub fn set_width(&mut self, value: u32)
pub fn set_height(&mut self, value: u32)
pub fn color_space(&self) -> Space
pub fn set_color_space(&mut self, value: Space)
pub fn color_range(&self) -> Range
pub fn set_color_range(&mut self, value: Range)
pub fn color_primaries(&self) -> Primaries
pub fn set_color_primaries(&mut self, value: Primaries)
pub fn color_transfer_characteristic(&self) -> TransferCharacteristic
pub fn set_color_transfer_characteristic( &mut self, value: TransferCharacteristic )
pub fn chroma_location(&self) -> Location
pub fn aspect_ratio(&self) -> Rational
pub fn coded_number(&self) -> usize
pub fn display_number(&self) -> usize
pub fn repeat(&self) -> f64
pub fn stride(&self, index: usize) -> usize
pub fn planes(&self) -> usize
pub fn plane_width(&self, index: usize) -> u32
pub fn plane_height(&self, index: usize) -> u32
pub fn plane<T: Component>(&self, index: usize) -> &[T] ⓘ
pub fn plane_mut<T: Component>(&mut self, index: usize) -> &mut [T] ⓘ
pub fn data_mut(&mut self, index: usize) -> &mut [u8] ⓘ
Methods from Deref<Target = Frame>§
pub unsafe fn as_ptr(&self) -> *const AVFrame
pub unsafe fn as_mut_ptr(&mut self) -> *mut AVFrame
pub unsafe fn is_empty(&self) -> bool
pub fn is_key(&self) -> bool
pub fn is_corrupt(&self) -> bool
pub fn packet(&self) -> Packet
pub fn pts(&self) -> Option<i64>
sourcepub fn set_pts(&mut self, value: Option<i64>)
pub fn set_pts(&mut self, value: Option<i64>)
Examples found in repository?
More examples
examples/transcode-x264.rs (line 108)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
fn receive_and_process_decoded_frames(
&mut self,
octx: &mut format::context::Output,
ost_time_base: Rational,
) {
let mut frame = frame::Video::empty();
while self.decoder.receive_frame(&mut frame).is_ok() {
self.frame_count += 1;
let timestamp = frame.timestamp();
self.log_progress(f64::from(
Rational(timestamp.unwrap_or(0) as i32, 1) * self.decoder.time_base(),
));
frame.set_pts(timestamp);
frame.set_kind(picture::Type::None);
self.send_frame_to_encoder(&frame);
self.receive_and_process_encoded_packets(octx, ost_time_base);
}
}
sourcepub fn timestamp(&self) -> Option<i64>
pub fn timestamp(&self) -> Option<i64>
Examples found in repository?
More examples
examples/transcode-x264.rs (line 104)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
fn receive_and_process_decoded_frames(
&mut self,
octx: &mut format::context::Output,
ost_time_base: Rational,
) {
let mut frame = frame::Video::empty();
while self.decoder.receive_frame(&mut frame).is_ok() {
self.frame_count += 1;
let timestamp = frame.timestamp();
self.log_progress(f64::from(
Rational(timestamp.unwrap_or(0) as i32, 1) * self.decoder.time_base(),
));
frame.set_pts(timestamp);
frame.set_kind(picture::Type::None);
self.send_frame_to_encoder(&frame);
self.receive_and_process_encoded_packets(octx, ost_time_base);
}
}