Struct AVFormatContext

Source
#[repr(C)]
pub struct AVFormatContext {
Show 74 fields pub av_class: *const AVClass, pub iformat: *mut AVInputFormat, pub oformat: *mut AVOutputFormat, pub priv_data: *mut c_void, pub pb: *mut AVIOContext, pub ctx_flags: c_int, pub nb_streams: c_uint, pub streams: *mut *mut AVStream, pub filename: [c_char; 1024], pub url: *mut c_char, pub start_time: i64, pub duration: i64, pub bit_rate: i64, pub packet_size: c_uint, pub max_delay: c_int, pub flags: c_int, pub probesize: i64, pub max_analyze_duration: i64, pub key: *const u8, pub keylen: c_int, pub nb_programs: c_uint, pub programs: *mut *mut AVProgram, pub video_codec_id: AVCodecID, pub audio_codec_id: AVCodecID, pub subtitle_codec_id: AVCodecID, pub max_index_size: c_uint, pub max_picture_buffer: c_uint, pub nb_chapters: c_uint, pub chapters: *mut *mut AVChapter, pub metadata: *mut AVDictionary, pub start_time_realtime: i64, pub fps_probe_size: c_int, pub error_recognition: c_int, pub interrupt_callback: AVIOInterruptCB, pub debug: c_int, pub max_interleave_delta: i64, pub strict_std_compliance: c_int, pub event_flags: c_int, pub max_ts_probe: c_int, pub avoid_negative_ts: c_int, pub ts_id: c_int, pub audio_preload: c_int, pub max_chunk_duration: c_int, pub max_chunk_size: c_int, pub use_wallclock_as_timestamps: c_int, pub avio_flags: c_int, pub duration_estimation_method: AVDurationEstimationMethod, pub skip_initial_bytes: i64, pub correct_ts_overflow: c_uint, pub seek2any: c_int, pub flush_packets: c_int, pub probe_score: c_int, pub format_probesize: c_int, pub codec_whitelist: *mut c_char, pub format_whitelist: *mut c_char, pub internal: *mut AVFormatInternal, pub io_repositioned: c_int, pub video_codec: *mut AVCodec, pub audio_codec: *mut AVCodec, pub subtitle_codec: *mut AVCodec, pub data_codec: *mut AVCodec, pub metadata_header_padding: c_int, pub opaque: *mut c_void, pub control_message_cb: av_format_control_message, pub output_ts_offset: i64, pub dump_separator: *mut u8, pub data_codec_id: AVCodecID, pub open_cb: Option<unsafe extern "C" fn(s: *mut AVFormatContext, p: *mut *mut AVIOContext, url: *const c_char, flags: c_int, int_cb: *const AVIOInterruptCB, options: *mut *mut AVDictionary) -> c_int>, pub protocol_whitelist: *mut c_char, pub io_open: Option<unsafe extern "C" fn(s: *mut AVFormatContext, pb: *mut *mut AVIOContext, url: *const c_char, flags: c_int, options: *mut *mut AVDictionary) -> c_int>, pub io_close: Option<unsafe extern "C" fn(s: *mut AVFormatContext, pb: *mut AVIOContext)>, pub protocol_blacklist: *mut c_char, pub max_streams: c_int, pub skip_estimate_duration_from_pts: c_int,
}
Expand description

Format I/O context. New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(AVFormatContext) must not be used outside libav*, use avformat_alloc_context() to create an AVFormatContext.

Fields can be accessed through AVOptions (av_opt*), the name string used matches the associated command line parameter name and can be found in libavformat/options_table.h. The AVOption/command line parameter names differ in some cases from the C structure field names for historic reasons or brevity.

Fields§

§av_class: *const AVClass

A class for logging and @ref avoptions. Set by avformat_alloc_context(). Exports (de)muxer private options if they exist.

§iformat: *mut AVInputFormat

The input container format.

Demuxing only, set by avformat_open_input().

§oformat: *mut AVOutputFormat

The output container format.

Muxing only, must be set by the caller before avformat_write_header().

§priv_data: *mut c_void

Format private data. This is an AVOptions-enabled struct if and only if iformat/oformat.priv_class is not NULL.

  • muxing: set by avformat_write_header()
  • demuxing: set by avformat_open_input()
§pb: *mut AVIOContext

I/O context.

  • demuxing: either set by the user before avformat_open_input() (then the user must close it manually) or set by avformat_open_input().
  • muxing: set by the user before avformat_write_header(). The caller must take care of closing / freeing the IO context.

Do NOT set this field if AVFMT_NOFILE flag is set in iformat/oformat.flags. In such a case, the (de)muxer will handle I/O in some other way and this field will be NULL.

§ctx_flags: c_int

Flags signalling stream properties. A combination of AVFMTCTX_*. Set by libavformat.

§nb_streams: c_uint

Number of elements in AVFormatContext.streams.

Set by avformat_new_stream(), must not be modified by any other code.

§streams: *mut *mut AVStream

A list of all streams in the file. New streams are created with avformat_new_stream().

  • demuxing: streams are created by libavformat in avformat_open_input(). If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also appear in av_read_frame().
  • muxing: streams are created by the user before avformat_write_header().

Freed by libavformat in avformat_free_context().

§filename: [c_char; 1024]

input or output filename

  • demuxing: set by avformat_open_input()
  • muxing: may be set by the caller before avformat_write_header()

@deprecated Use url instead.

§url: *mut c_char

input or output URL. Unlike the old filename field, this field has no length restriction.

  • demuxing: set by avformat_open_input(), initialized to an empty string if url parameter was NULL in avformat_open_input().
  • muxing: may be set by the caller before calling avformat_write_header() (or avformat_init_output() if that is called first) to a string which is freeable by av_free(). Set to an empty string if it was NULL in avformat_init_output().

Freed by libavformat in avformat_free_context().

§start_time: i64

Position of the first frame of the component, in AV_TIME_BASE fractional seconds. NEVER set this value directly: It is deduced from the AVStream values.

Demuxing only, set by libavformat.

§duration: i64

Duration of the stream, in AV_TIME_BASE fractional seconds. Only set this value if you know none of the individual stream durations and also do not set any of them. This is deduced from the AVStream values if not set.

Demuxing only, set by libavformat.

§bit_rate: i64

Total stream bitrate in bit/s, 0 if not available. Never set it directly if the file_size and the duration are known as FFmpeg can compute it automatically.

§packet_size: c_uint§max_delay: c_int§flags: c_int

Flags modifying the (de)muxer behaviour. A combination of AVFMT_FLAG_*. Set by the user before avformat_open_input() / avformat_write_header().

§probesize: i64

Maximum size of the data read from input for determining the input container format. Demuxing only, set by the caller before avformat_open_input().

§max_analyze_duration: i64

Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info(). Demuxing only, set by the caller before avformat_find_stream_info(). Can be set to 0 to let avformat choose using a heuristic.

§key: *const u8§keylen: c_int§nb_programs: c_uint§programs: *mut *mut AVProgram§video_codec_id: AVCodecID

Forced video codec_id. Demuxing: Set by user.

§audio_codec_id: AVCodecID

Forced audio codec_id. Demuxing: Set by user.

§subtitle_codec_id: AVCodecID

Forced subtitle codec_id. Demuxing: Set by user.

§max_index_size: c_uint

Maximum amount of memory in bytes to use for the index of each stream. If the index exceeds this size, entries will be discarded as needed to maintain a smaller size. This can lead to slower or less accurate seeking (depends on demuxer). Demuxers for which a full in-memory index is mandatory will ignore this.

  • muxing: unused
  • demuxing: set by user
§max_picture_buffer: c_uint

Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices.

§nb_chapters: c_uint

Number of chapters in AVChapter array. When muxing, chapters are normally written in the file header, so nb_chapters should normally be initialized before write_header is called. Some muxers (e.g. mov and mkv) can also write chapters in the trailer. To write chapters in the trailer, nb_chapters must be zero when write_header is called and non-zero when write_trailer is called.

  • muxing: set by user
  • demuxing: set by libavformat
§chapters: *mut *mut AVChapter§metadata: *mut AVDictionary

Metadata that applies to the whole file.

  • demuxing: set by libavformat in avformat_open_input()
  • muxing: may be set by the caller before avformat_write_header()

Freed by libavformat in avformat_free_context().

§start_time_realtime: i64

Start time of the stream in real world time, in microseconds since the Unix epoch (00:00 1st January 1970). That is, pts=0 in the stream was captured at this real world time.

  • muxing: Set by the caller before avformat_write_header(). If set to either 0 or AV_NOPTS_VALUE, then the current wall-time will be used.
  • demuxing: Set by libavformat. AV_NOPTS_VALUE if unknown. Note that the value may become known after some number of frames have been received.
§fps_probe_size: c_int

The number of frames used for determining the framerate in avformat_find_stream_info(). Demuxing only, set by the caller before avformat_find_stream_info().

§error_recognition: c_int

Error recognition; higher values will detect more errors but may misdetect some more or less valid parts as errors. Demuxing only, set by the caller before avformat_open_input().

§interrupt_callback: AVIOInterruptCB

Custom interrupt callbacks for the I/O layer.

demuxing: set by the user before avformat_open_input(). muxing: set by the user before avformat_write_header() (mainly useful for AVFMT_NOFILE formats). The callback should also be passed to avio_open2() if it’s used to open the file.

§debug: c_int

Flags to enable debugging.

§max_interleave_delta: i64

Maximum buffering duration for interleaving.

To ensure all the streams are interleaved correctly, av_interleaved_write_frame() will wait until it has at least one packet for each stream before actually writing any packets to the output file. When some streams are “sparse” (i.e. there are large gaps between successive packets), this can result in excessive buffering.

This field specifies the maximum difference between the timestamps of the first and the last packet in the muxing queue, above which libavformat will output a packet regardless of whether it has queued a packet for all the streams.

Muxing only, set by the caller before avformat_write_header().

§strict_std_compliance: c_int

Allow non-standard and experimental extension @see AVCodecContext.strict_std_compliance

§event_flags: c_int

Flags for the user to detect events happening on the file. Flags must be cleared by the user once the event has been handled. A combination of AVFMT_EVENT_FLAG_*.

§max_ts_probe: c_int

Maximum number of packets to read while waiting for the first timestamp. Decoding only.

§avoid_negative_ts: c_int

Avoid negative timestamps during muxing. Any value of the AVFMT_AVOID_NEG_TS_* constants. Note, this only works when using av_interleaved_write_frame. (interleave_packet_per_dts is in use)

  • muxing: Set by user
  • demuxing: unused
§ts_id: c_int

Transport stream id. This will be moved into demuxer private options. Thus no API/ABI compatibility

§audio_preload: c_int

Audio preload in microseconds. Note, not all formats support this and unpredictable things may happen if it is used when not supported.

  • encoding: Set by user
  • decoding: unused
§max_chunk_duration: c_int

Max chunk time in microseconds. Note, not all formats support this and unpredictable things may happen if it is used when not supported.

  • encoding: Set by user
  • decoding: unused
§max_chunk_size: c_int

Max chunk size in bytes Note, not all formats support this and unpredictable things may happen if it is used when not supported.

  • encoding: Set by user
  • decoding: unused
§use_wallclock_as_timestamps: c_int

forces the use of wallclock timestamps as pts/dts of packets This has undefined results in the presence of B frames.

  • encoding: unused
  • decoding: Set by user
§avio_flags: c_int

avio flags, used to force AVIO_FLAG_DIRECT.

  • encoding: unused
  • decoding: Set by user
§duration_estimation_method: AVDurationEstimationMethod

The duration field can be estimated through various ways, and this field can be used to know how the duration was estimated.

  • encoding: unused
  • decoding: Read by user
§skip_initial_bytes: i64

Skip initial bytes when opening stream

  • encoding: unused
  • decoding: Set by user
§correct_ts_overflow: c_uint

Correct single timestamp overflows

  • encoding: unused
  • decoding: Set by user
§seek2any: c_int

Force seeking to any (also non key) frames.

  • encoding: unused
  • decoding: Set by user
§flush_packets: c_int

Flush the I/O context after each packet.

  • encoding: Set by user
  • decoding: unused
§probe_score: c_int

format probing score. The maximal score is AVPROBE_SCORE_MAX, its set when the demuxer probes the format.

  • encoding: unused
  • decoding: set by avformat, read by user
§format_probesize: c_int

number of bytes to read maximally to identify format.

  • encoding: unused
  • decoding: set by user
§codec_whitelist: *mut c_char

‘,’ separated list of allowed decoders. If NULL then all are allowed

  • encoding: unused
  • decoding: set by user
§format_whitelist: *mut c_char

‘,’ separated list of allowed demuxers. If NULL then all are allowed

  • encoding: unused
  • decoding: set by user
§internal: *mut AVFormatInternal

An opaque field for libavformat internal usage. Must not be accessed in any way by callers.

§io_repositioned: c_int

IO repositioned flag. This is set by avformat when the underlaying IO context read pointer is repositioned, for example when doing byte based seeking. Demuxers can use the flag to detect such changes.

§video_codec: *mut AVCodec

Forced video codec. This allows forcing a specific decoder, even when there are multiple with the same codec_id. Demuxing: Set by user

§audio_codec: *mut AVCodec

Forced audio codec. This allows forcing a specific decoder, even when there are multiple with the same codec_id. Demuxing: Set by user

§subtitle_codec: *mut AVCodec

Forced subtitle codec. This allows forcing a specific decoder, even when there are multiple with the same codec_id. Demuxing: Set by user

§data_codec: *mut AVCodec

Forced data codec. This allows forcing a specific decoder, even when there are multiple with the same codec_id. Demuxing: Set by user

§metadata_header_padding: c_int

Number of bytes to be written as padding in a metadata header. Demuxing: Unused. Muxing: Set by user via av_format_set_metadata_header_padding.

§opaque: *mut c_void

User data. This is a place for some private data of the user.

§control_message_cb: av_format_control_message

Callback used by devices to communicate with application.

§output_ts_offset: i64

Output timestamp offset, in microseconds. Muxing: set by user

§dump_separator: *mut u8

dump format separator. can be “, “ or “\n “ or anything else

  • muxing: Set by user.
  • demuxing: Set by user.
§data_codec_id: AVCodecID

Forced Data codec_id. Demuxing: Set by user.

§open_cb: Option<unsafe extern "C" fn(s: *mut AVFormatContext, p: *mut *mut AVIOContext, url: *const c_char, flags: c_int, int_cb: *const AVIOInterruptCB, options: *mut *mut AVDictionary) -> c_int>

Called to open further IO contexts when needed for demuxing.

This can be set by the user application to perform security checks on the URLs before opening them. The function should behave like avio_open2(), AVFormatContext is provided as contextual information and to reach AVFormatContext.opaque.

If NULL then some simple checks are used together with avio_open2().

Must not be accessed directly from outside avformat. @See av_format_set_open_cb()

Demuxing: Set by user.

@deprecated Use io_open and io_close.

§protocol_whitelist: *mut c_char

‘,’ separated list of allowed protocols.

  • encoding: unused
  • decoding: set by user
§io_open: Option<unsafe extern "C" fn(s: *mut AVFormatContext, pb: *mut *mut AVIOContext, url: *const c_char, flags: c_int, options: *mut *mut AVDictionary) -> c_int>

A callback for opening new IO streams.

Whenever a muxer or a demuxer needs to open an IO stream (typically from avformat_open_input() for demuxers, but for certain formats can happen at other times as well), it will call this callback to obtain an IO context.

@param s the format context @param pb on success, the newly opened IO context should be returned here @param url the url to open @param flags a combination of AVIO_FLAG_* @param options a dictionary of additional options, with the same semantics as in avio_open2() @return 0 on success, a negative AVERROR code on failure

@note Certain muxers and demuxers do nesting, i.e. they open one or more additional internal format contexts. Thus the AVFormatContext pointer passed to this callback may be different from the one facing the caller. It will, however, have the same ‘opaque’ field.

§io_close: Option<unsafe extern "C" fn(s: *mut AVFormatContext, pb: *mut AVIOContext)>

A callback for closing the streams opened with AVFormatContext.io_open().

§protocol_blacklist: *mut c_char

‘,’ separated list of disallowed protocols.

  • encoding: unused
  • decoding: set by user
§max_streams: c_int

The maximum number of streams.

  • encoding: unused
  • decoding: set by user
§skip_estimate_duration_from_pts: c_int

Skip duration calcuation in estimate_timings_from_pts.

  • encoding: unused
  • decoding: set by user

Trait Implementations§

Source§

impl Clone for AVFormatContext

Source§

fn clone(&self) -> AVFormatContext

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AVFormatContext

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.