Core functions

Functions for querying libavformat capabilities, allocating core structures, etc. More...

Modules

 Demuxing
 Demuxers read a media file and split it into chunks of data (packets).

Functions

unsigned avformat_version (void)
 Return the LIBAVFORMAT_VERSION_INT constant.
const char * avformat_configuration (void)
 Return the libavformat build-time configuration.
const char * avformat_license (void)
 Return the libavformat license.
void av_register_all (void)
 Initialize libavformat and register all the muxers, demuxers and protocols.
void av_register_input_format (AVInputFormat *format)
void av_register_output_format (AVOutputFormat *format)
int avformat_network_init (void)
 Do global initialization of network components.
int avformat_network_deinit (void)
 Undo the initialization done by avformat_network_init.
AVInputFormatav_iformat_next (AVInputFormat *f)
 If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registered input format after f or NULL if f is the last one.
AVOutputFormatav_oformat_next (AVOutputFormat *f)
 If f is NULL, returns the first registered output format, if f is non-NULL, returns the next registered output format after f or NULL if f is the last one.
AVFormatContextavformat_alloc_context (void)
 Allocate an AVFormatContext.
void avformat_free_context (AVFormatContext *s)
 Free an AVFormatContext and all its streams.
const AVClassavformat_get_class (void)
 Get the AVClass for AVFormatContext.
AVStreamavformat_new_stream (AVFormatContext *s, AVCodec *c)
 Add a new stream to a media file.
AVProgramav_new_program (AVFormatContext *s, int id)

Detailed Description

Functions for querying libavformat capabilities, allocating core structures, etc.

< full parsing and repack

< Only parse headers, do not repack.

< full parsing and interpolation of timestamps for frames not starting on a packet boundary

< full parsing and repack of the first frame only, only implemented for H.264 currently

< Minimum distance between this and the previous keyframe, used to avoid unneeded searching.

Track should be used during playback by default. Useful for subtitle track that should be displayed even when user did not explicitly ask for subtitles.

The stream is stored in the file as an attached picture/"cover art" (e.g. APIC frame in ID3v2). The single packet associated with it will be returned among the first few packets read from the file unless seeking takes place. It can also be accessed at any time in AVStream.attached_pic.

Stream structure. 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(AVStream) must not be used outside libav*.

< stream index in AVFormatContext

Format-specific stream ID. decoding: set by libavformat encoding: set by the user, replaced by libavformat if left unset

Codec context associated with this stream. Allocated and freed by libavformat.

Real base framerate of the stream. This is the lowest framerate with which all timestamps can be represented accurately (it is the least common multiple of all framerates in the stream). Note, this value is just a guess! For example, if the time base is 1/90000 and all frames have either approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.

encoding: pts generation when outputting stream

This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.

decoding: set by libavformat encoding: set by libavformat in avformat_write_header. The muxer may use the user-provided value of codec->time_base as a hint.

Decoding: pts of the first frame of the stream, in stream time base. Only set this if you are absolutely 100% sure that the value you set it to really is the pts of the first frame. This may be undefined (AV_NOPTS_VALUE).

Decoding: duration of the stream, in stream time base. If a source file does not specify a duration, but does specify a bitrate, this value will be estimated from bitrate and file size.

< number of frames in this stream if known or 0

< AV_DISPOSITION_* bit field

< Selects which packets can be discarded at will and do not need to be demuxed.

sample aspect ratio (0 if unknown)

Average framerate

For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached picture.

decoding: set by libavformat, must not be modified by the caller. encoding: unused

Stream information used internally by av_find_stream_info()

Those are used for average framerate estimation.

< number of bits in pts (used for wrapping control)

Timestamp corresponding to the last dts sync point.

Initialized when AVCodecParserContext.dts_sync_point >= 0 and a DTS is received from the underlying container. Otherwise set to AV_NOPTS_VALUE by default.

Number of packets to buffer for codec probing

Number of frames that have been demuxed during av_find_stream_info()

last packet in packet_buffer for this stream when muxing.

< Only used if the format does not support seeking natively.

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(AVProgram) must not be used outside libav*.

< selects which program to discard and which to feed to the caller

< unique ID to identify the chapter

< time base in which the start/end timestamps are specified

< chapter start/end time in time_base units

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.

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

Can only be iformat or oformat, not both at the same time.

decoding: set by avformat_open_input(). encoding: set by the user.

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

I/O context.

decoding: either set by the user before avformat_open_input() (then the user must close it manually) or set by avformat_open_input(). encoding: set by the user.

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.

< Format-specific flags, see AVFMTCTX_xx

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

decoding: 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(). encoding: streams are created by the user before avformat_write_header().

< input or output filename

Decoding: 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.

Decoding: 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.

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

decoding: size of data to probe; encoding: unused.

decoding: maximum time (in AV_TIME_BASE units) during which the input should be analyzed in avformat_find_stream_info().

Forced video codec_id. Demuxing: Set by user.

Forced audio codec_id. Demuxing: Set by user.

Forced subtitle codec_id. Demuxing: Set by user.

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

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

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.

decoding: number of frames used to probe fps

Error recognition; higher values will detect more errors but may misdetect some more or less valid parts as errors.

Custom interrupt callbacks for the I/O layer.

decoding: set by the user before avformat_open_input(). encoding: 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.

Flags to enable debugging.

This buffer is only needed when packets were already buffered but not decoded, for example to get the codec parameters in MPEG streams.

< offset of the first packet

Raw packets from the demuxer, prior to parsing and decoding. This buffer is used for buffering packets until the codec can be identified, as parsing cannot be done without knowing the codec.

Packets split by the parser get queued here.

Remaining size available for raw_packet_buffer, in bytes.

Functions for querying libavformat capabilities, allocating core structures, etc.

Function Documentation

AVInputFormat* av_iformat_next ( AVInputFormat f)

If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registered input format after f or NULL if f is the last one.

Definition at line 76 of file utils.c.

Referenced by av_find_input_format(), av_probe_input_format2(), format_child_class_next(), probe(), and show_formats().

AVProgram* av_new_program ( AVFormatContext s,
int  id 
)

Definition at line 2792 of file utils.c.

Referenced by pat_cb(), and sdt_cb().

AVOutputFormat* av_oformat_next ( AVOutputFormat f)

If f is NULL, returns the first registered output format, if f is non-NULL, returns the next registered output format after f or NULL if f is the last one.

Definition at line 82 of file utils.c.

Referenced by av_guess_format(), format_child_class_next(), and show_formats().

void av_register_all ( void  )

Initialize libavformat and register all the muxers, demuxers and protocols.

If you do not call this function, then you can select exactly which formats you want to support.

See Also
av_register_input_format()
av_register_output_format()
av_register_protocol()

Definition at line 52 of file allformats.c.

Referenced by main(), and movie_init().

void av_register_input_format ( AVInputFormat format)

Definition at line 88 of file utils.c.

void av_register_output_format ( AVOutputFormat format)

Definition at line 97 of file utils.c.

const char* avformat_configuration ( void  )

Return the libavformat build-time configuration.

Definition at line 60 of file utils.c.

const AVClass* avformat_get_class ( void  )

Get the AVClass for AVFormatContext.

It can be used in combination with AV_OPT_SEARCH_FAKE_OBJ for examining options.

See Also
av_opt_find().

Definition at line 106 of file options.c.

Referenced by opt_default(), and show_help_default().

const char* avformat_license ( void  )

Return the libavformat license.

Definition at line 65 of file utils.c.

int avformat_network_deinit ( void  )

Undo the initialization done by avformat_network_init.

Definition at line 3540 of file utils.c.

Referenced by do_exit(), exit_program(), and main().

int avformat_network_init ( void  )

Do global initialization of network components.

This is optional, but recommended, since it avoids the overhead of implicitly doing the setup for each session.

Calling this function will become mandatory if using network protocols at some major version bump.

Definition at line 3528 of file utils.c.

Referenced by main().

AVStream* avformat_new_stream ( AVFormatContext s,
AVCodec c 
)

Add a new stream to a media file.

When demuxing, it is called by the demuxer in read_header(). If the flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also be called in read_packet().

When muxing, should be called by the user before avformat_write_header().

Parameters
cIf non-NULL, the AVCodecContext corresponding to the new stream will be initialized to use this codec. This is needed for e.g. codec-specific defaults to be set, so codec should be provided if it is known.
Returns
newly created stream or NULL on error.
Examples:
libavformat/output-example.c.

Definition at line 2736 of file utils.c.

Referenced by add_audio_stream(), add_dstream(), add_video_stream(), adts_aac_read_header(), adx_read_header(), aea_read_header(), aiff_read_header(), amr_read_header(), apc_read_header(), ape_read_header(), ape_tag_read_field(), asf_read_picture(), asf_read_stream_properties(), audio_read_header(), avi_read_header(), avisynth_read_header(), avpriv_dv_init_demux(), avs_read_packet(), bfi_read_header(), bmv_read_header(), cdata_read_header(), cdxl_read_packet(), cin_read_header(), create_audio_stream(), create_stream(), daud_header(), dc1394_read_common(), decode_main_header(), dfa_read_header(), dv_extract_audio_info(), dxa_read_header(), ea_read_header(), fbdev_read_header(), ff_id3v2_parse_apic(), ff_raw_audio_read_header(), ff_raw_video_read_header(), ff_rtp_chain_mux_open(), ffm_read_header(), film_read_header(), flac_read_header(), g722_read_header(), g723_1_init(), get_attachment(), get_sindex(), grab_read_header(), gsm_read_header(), hls_mux_init(), hls_read_header(), idcin_read_header(), iff_read_header(), ilbc_read_header(), img_read_header(), ipmovie_read_header(), ism_write_header(), iss_read_header(), lmlm4_read_header(), lxf_read_header(), matroska_read_header(), mmf_read_header(), mov_read_covr(), mov_read_trak(), mp3_read_header(), mpc8_read_header(), mpc_read_header(), mpegps_read_packet(), mpegts_push_data(), mpegts_read_header(), mpegts_set_stream_info(), mpegts_write_header(), msnwc_tcp_read_header(), mtv_read_header(), mxf_parse_structural_metadata(), mxg_read_header(), nc_read_header(), new_output_stream(), new_stream(), nsv_parse_NSVs_header(), nuv_header(), ogg_new_stream(), oma_read_header(), parse_picture(), parse_strk(), parse_vtrk(), pcm_read_header(), pmp_header(), pmt_cb(), pulse_read_header(), pva_read_header(), qcp_read_header(), r3d_read_red1(), rawvideo_read_header(), read_desc_chunk(), read_frame(), read_header(), read_packet(), rl2_read_header(), rm_read_header(), rm_read_header_old(), roq_read_packet(), rpl_read_header(), rso_read_header(), sap_fetch_packet(), sap_read_header(), segment_mux_init(), seq_read_header(), siff_parse_vbv1(), smacker_read_header(), smjpeg_read_header(), sol_read_header(), sox_read_header(), spdif_read_packet(), srt_read_header(), str_read_packet(), swf_read_packet(), tak_read_header(), thp_read_header(), tmv_read_header(), tta_read_header(), txd_read_header(), v4l2_read_header(), vc1t_read_header(), vfw_read_header(), vid_read_packet(), vmd_read_header(), voc_read_header(), vqf_read_header(), wc3_read_header(), wsaud_read_header(), wsvqa_read_header(), wsvqa_read_packet(), wv_read_header(), x11grab_read_header(), xa_read_header(), xmv_read_header(), xwma_read_header(), yop_read_header(), and yuv4_read_header().

unsigned avformat_version ( void  )

Return the LIBAVFORMAT_VERSION_INT constant.

Definition at line 55 of file utils.c.