FFmpeg
Loading...
Searching...
No Matches
Topics | Files
libavformat

I/O and Muxing/Demuxing Library. More...

Topics

  Demuxers read a media file and split it into chunks of data (packets).
 
  Muxing
  Muxers take encoded data in the form of AVPackets and write it into files or other output bytestreams in the specified container format.
 
 
 
 
 
  The metadata API allows libavformat to export metadata tags to a client application when demuxing.
 
  Functions for querying libavformat capabilities, allocating core structures, etc.
 
  Miscellaneous utility functions related to both muxing and demuxing (or neither).
 

Files

file   avformat.h
  Main libavformat public API header.
 
file   version.h
  Libavformat version macros.
 
file   version_major.h
  Libavformat version macros.
 

Detailed Description

I/O and Muxing/Demuxing Library.

Libavformat (lavf) is a library for dealing with various media container formats. Its main two purposes are demuxing - i.e. splitting a media file into component streams, and the reverse process of muxing - writing supplied data in a specified container format. It also has an I/O module which supports a number of protocols for accessing the data (e.g. file, tcp, http and others). Unless you are absolutely sure you won't use libavformat's network capabilities, you should also call avformat_network_init().

A supported input format is described by an AVInputFormat struct, conversely an output format is described by AVOutputFormat. You can iterate over all input/output formats using the av_demuxer_iterate / av_muxer_iterate() functions. The protocols layer is not part of the public API, so you can only get the names of supported protocols with the avio_enum_protocols() function.

Main lavf structure used for both muxing and demuxing is AVFormatContext, which exports all information about the file being read or written. As with most Libavformat structures, its size is not part of public ABI, so it cannot be allocated on stack or directly with av_malloc(). To create an AVFormatContext, use avformat_alloc_context() (some functions, like avformat_open_input() might do that for you).

Most importantly an AVFormatContext contains:

  • the input or output format. It is either autodetected or set by user for input; always set by user for output.
  • an array of AVStreams, which describe all elementary streams stored in the file. AVStreams are typically referred to using their index in this array.
  • an I/O context. It is either opened by lavf or set by user for input, always set by user for output (unless you are dealing with an AVFMT_NOFILE format).

Passing options to (de)muxers

It is possible to configure lavf muxers and demuxers using the AVOptions mechanism. Generic (format-independent) libavformat options are provided by AVFormatContext, they can be examined from a user program by calling av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass from avformat_get_class()). Private (format-specific) options are provided by AVFormatContext.priv_data if and only if AVInputFormat.priv_class / AVOutputFormat.priv_class of the corresponding format struct is non-NULL. Further options may be provided by the I/O context, if its AVClass is non-NULL, and the protocols layer. See the discussion on nesting in AVOptions documentation to learn how to access those.

urls

URL strings in libavformat are made of a scheme/protocol, a ':', and a scheme specific string. URLs without a scheme and ':' used for local files are supported but deprecated. "file:" should be used for local files.

It is important that the scheme string is not taken from untrusted sources without checks.

Note that some schemes/protocols are quite powerful, allowing access to both local and remote files, parts of them, concatenations of them, local audio and video devices and so on.


Generated on Sat Sep 5 2026 19:21:24 for FFmpeg by doxygen 1.13.2

AltStyle によって変換されたページ (->オリジナル) /