pub struct Encoder { /* private fields */ }Expand description
Encodes frames into a video stream.
§Example
ⓘ
let encoder = Encoder::new(
Path::new("video_in.mp4"),
Settings::for_h264_yuv420p(800, 600, 30.0)
)
.unwrap();
let decoder = Decoder::new(Path::new("video_out.mkv")).unwrap();
decoder
.decode_iter()
.take_while(Result::is_ok)
.map(|frame| encoder
.encode(frame.unwrap())
.expect("Failed to encode frame."),
);Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn new(
destination: impl Into<Location>,
settings: Settings,
) -> Result<Self, Error>
pub fn new( destination: impl Into<Location>, settings: Settings, ) -> Result<Self, Error>
Create an encoder with the specified destination and settings.
destination- Where to encode to.settings- Encoding settings.
Sourcepub fn encode(
&mut self,
frame: &Frame,
source_timestamp: Time,
) -> Result<(), Error>
pub fn encode( &mut self, frame: &Frame, source_timestamp: Time, ) -> Result<(), Error>
Encode a single ndarray frame.
§Arguments
frame- Frame to encode inHWCformat and standard layout.source_timestamp- Frame timestamp of original source. This is necessary to make sure the output will be timed correctly.
Sourcepub fn finish(&mut self) -> Result<(), Error>
pub fn finish(&mut self) -> Result<(), Error>
Signal to the encoder that writing has finished. This will cause any packets in the encoder to be flushed and a trailer to be written if the container format has one.
Note: If you don’t call this function before dropping the encoder, it will be called automatically. This will block the caller thread. Any errors cannot be propagated in this case.
Sourcepub fn time_base(&self) -> AvRational
pub fn time_base(&self) -> AvRational
Get encoder time base.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl !RefUnwindSafe for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl !UnwindSafe for Encoder
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