Skip to main content

OutputFile

Struct OutputFile 

Source
pub struct OutputFile(/* private fields */);
Expand description

A container opened for writing whose file is closed without panicking.

Self::close reports the error closing the file returns: a write that failed earlier, or one the file system only reports at close(2). Dropping it closes the file and discards that error, which is what an abandoned output wants.

Implementations§

Source§

impl OutputFile

Source

pub fn create(filename: &CStr, format: &CStr) -> Result<Self, RsmpegError>

Creates the output with the FFmpeg muxer named format (mp4, mov, matroska, webm), and opens filename for it. Nothing is guessed from the file name.

§Errors

When there is no such muxer or the file cannot be opened.

Source

pub fn close(self) -> Result<(), BridgeError>

Closes the file, after the trailer.

§Errors

The error the file’s I/O reports on closing.

Methods from Deref<Target = AVFormatContextOutput>§

Source

pub fn as_ptr(&self) -> *const AVFormatContext

Source

pub fn as_mut_ptr(&mut self) -> *mut AVFormatContext

Source

pub unsafe fn set_ptr(&mut self, ptr: NonNull<AVFormatContext>)

§Safety

This function should only be called when the pointer is valid and the data it’s pointing to can be dropped.

Source

pub fn write_header( &mut self, dict: &mut Option<AVDictionary>, ) -> Result<(), RsmpegError>

Allocate the stream private data and write the stream header to an output media file.

  • options: An AVDictionary filled with AVFormatContextInput and muxer-private options. On return this parameter will be replaced with a dict containing options that were not found. Set this to None if it’s not needed.
Source

pub fn write_trailer(&mut self) -> Result<(), RsmpegError>

Write the stream trailer to an output media file and free the file private data.

Source

pub fn dump(&mut self, index: i32, filename: &CStr) -> Result<(), RsmpegError>

Dump ffi::AVFormatContext info in the “FFmpeg” way.

The filename here is just for info printing, it’s really doesn’t matter.

Source

pub fn write_frame(&mut self, packet: &mut AVPacket) -> Result<(), RsmpegError>

Write a packet to an output media file.

This function passes the packet directly to the muxer, without any buffering or reordering. The caller is responsible for correctly interleaving the packets if the format requires it. Callers that want libavformat to handle the interleaving should call Self::interleaved_write_frame() instead of this function.

Source

pub fn interleaved_write_frame( &mut self, packet: &mut AVPacket, ) -> Result<(), RsmpegError>

Write a packet to an output media file ensuring correct interleaving.

This function will buffer the packets internally as needed to make sure the packets in the output file are properly interleaved in the order of increasing dts. Callers doing their own interleaving should call Self::write_frame() instead of this function.

Source

pub fn streams(&'stream self) -> &'stream [AVStreamRef<'stream>]

Return slice of AVStreamRef.

Source

pub fn oformat(&self) -> AVOutputFormatRef<'static>

Source

pub fn set_oformat(&mut self, format: AVOutputFormatRef<'static>)

Source

pub fn new_stream(&'stream mut self) -> AVStreamMut<'stream>

Add a new stream to a media file, should be called by the user before Self::write_header();

Trait Implementations§

Source§

impl Deref for OutputFile

Source§

type Target = AVFormatContextOutput

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for OutputFile

Source§

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

Mutably dereferences the value.
Source§

impl Drop for OutputFile

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.