Path: blob/master/dep/ffmpeg/include/libavformat/avformat.h
7436 views
/*1* copyright (c) 2001 Fabrice Bellard2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVFORMAT_AVFORMAT_H21#define AVFORMAT_AVFORMAT_H2223/**24* @file25* @ingroup libavf26* Main libavformat public API header27*/2829/**30* @defgroup libavf libavformat31* I/O and Muxing/Demuxing Library32*33* Libavformat (lavf) is a library for dealing with various media container34* formats. Its main two purposes are demuxing - i.e. splitting a media file35* into component streams, and the reverse process of muxing - writing supplied36* data in a specified container format. It also has an @ref lavf_io37* "I/O module" which supports a number of protocols for accessing the data (e.g.38* file, tcp, http and others).39* Unless you are absolutely sure you won't use libavformat's network40* capabilities, you should also call avformat_network_init().41*42* A supported input format is described by an AVInputFormat struct, conversely43* an output format is described by AVOutputFormat. You can iterate over all44* input/output formats using the av_demuxer_iterate / av_muxer_iterate() functions.45* The protocols layer is not part of the public API, so you can only get the names46* of supported protocols with the avio_enum_protocols() function.47*48* Main lavf structure used for both muxing and demuxing is AVFormatContext,49* which exports all information about the file being read or written. As with50* most Libavformat structures, its size is not part of public ABI, so it cannot be51* allocated on stack or directly with av_malloc(). To create an52* AVFormatContext, use avformat_alloc_context() (some functions, like53* avformat_open_input() might do that for you).54*55* Most importantly an AVFormatContext contains:56* @li the @ref AVFormatContext.iformat "input" or @ref AVFormatContext.oformat57* "output" format. It is either autodetected or set by user for input;58* always set by user for output.59* @li an @ref AVFormatContext.streams "array" of AVStreams, which describe all60* elementary streams stored in the file. AVStreams are typically referred to61* using their index in this array.62* @li an @ref AVFormatContext.pb "I/O context". It is either opened by lavf or63* set by user for input, always set by user for output (unless you are dealing64* with an AVFMT_NOFILE format).65*66* @section lavf_options Passing options to (de)muxers67* It is possible to configure lavf muxers and demuxers using the @ref avoptions68* mechanism. Generic (format-independent) libavformat options are provided by69* AVFormatContext, they can be examined from a user program by calling70* av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass71* from avformat_get_class()). Private (format-specific) options are provided by72* AVFormatContext.priv_data if and only if AVInputFormat.priv_class /73* AVOutputFormat.priv_class of the corresponding format struct is non-NULL.74* Further options may be provided by the @ref AVFormatContext.pb "I/O context",75* if its AVClass is non-NULL, and the protocols layer. See the discussion on76* nesting in @ref avoptions documentation to learn how to access those.77*78* @section urls79* URL strings in libavformat are made of a scheme/protocol, a ':', and a80* scheme specific string. URLs without a scheme and ':' used for local files81* are supported but deprecated. "file:" should be used for local files.82*83* It is important that the scheme string is not taken from untrusted84* sources without checks.85*86* Note that some schemes/protocols are quite powerful, allowing access to87* both local and remote files, parts of them, concatenations of them, local88* audio and video devices and so on.89*90* @{91*92* @defgroup lavf_decoding Demuxing93* @{94* Demuxers read a media file and split it into chunks of data (@em packets). A95* @ref AVPacket "packet" contains one or more encoded frames which belongs to a96* single elementary stream. In the lavf API this process is represented by the97* avformat_open_input() function for opening a file, av_read_frame() for98* reading a single packet and finally avformat_close_input(), which does the99* cleanup.100*101* @section lavf_decoding_open Opening a media file102* The minimum information required to open a file is its URL, which103* is passed to avformat_open_input(), as in the following code:104* @code105* const char *url = "file:in.mp3";106* AVFormatContext *s = NULL;107* int ret = avformat_open_input(&s, url, NULL, NULL);108* if (ret < 0)109* abort();110* @endcode111* The above code attempts to allocate an AVFormatContext, open the112* specified file (autodetecting the format) and read the header, exporting the113* information stored there into s. Some formats do not have a header or do not114* store enough information there, so it is recommended that you call the115* avformat_find_stream_info() function which tries to read and decode a few116* frames to find missing information.117*118* In some cases you might want to preallocate an AVFormatContext yourself with119* avformat_alloc_context() and do some tweaking on it before passing it to120* avformat_open_input(). One such case is when you want to use custom functions121* for reading input data instead of lavf internal I/O layer.122* To do that, create your own AVIOContext with avio_alloc_context(), passing123* your reading callbacks to it. Then set the @em pb field of your124* AVFormatContext to newly created AVIOContext.125*126* Since the format of the opened file is in general not known until after127* avformat_open_input() has returned, it is not possible to set demuxer private128* options on a preallocated context. Instead, the options should be passed to129* avformat_open_input() wrapped in an AVDictionary:130* @code131* AVDictionary *options = NULL;132* av_dict_set(&options, "video_size", "640x480", 0);133* av_dict_set(&options, "pixel_format", "rgb24", 0);134*135* if (avformat_open_input(&s, url, NULL, &options) < 0)136* abort();137* av_dict_free(&options);138* @endcode139* This code passes the private options 'video_size' and 'pixel_format' to the140* demuxer. They would be necessary for e.g. the rawvideo demuxer, since it141* cannot know how to interpret raw video data otherwise. If the format turns142* out to be something different than raw video, those options will not be143* recognized by the demuxer and therefore will not be applied. Such unrecognized144* options are then returned in the options dictionary (recognized options are145* consumed). The calling program can handle such unrecognized options as it146* wishes, e.g.147* @code148* const AVDictionaryEntry *e;149* if ((e = av_dict_iterate(options, NULL))) {150* fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);151* abort();152* }153* @endcode154*155* After you have finished reading the file, you must close it with156* avformat_close_input(). It will free everything associated with the file.157*158* @section lavf_decoding_read Reading from an opened file159* Reading data from an opened AVFormatContext is done by repeatedly calling160* av_read_frame() on it. Each call, if successful, will return an AVPacket161* containing encoded data for one AVStream, identified by162* AVPacket.stream_index. This packet may be passed straight into the libavcodec163* decoding functions avcodec_send_packet() or avcodec_decode_subtitle2() if the164* caller wishes to decode the data.165*166* AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be167* set if known. They may also be unset (i.e. AV_NOPTS_VALUE for168* pts/dts, 0 for duration) if the stream does not provide them. The timing169* information will be in AVStream.time_base units, i.e. it has to be170* multiplied by the timebase to convert them to seconds.171*172* A packet returned by av_read_frame() is always reference-counted,173* i.e. AVPacket.buf is set and the user may keep it indefinitely.174* The packet must be freed with av_packet_unref() when it is no175* longer needed.176*177* @section lavf_decoding_seek Seeking178* @}179*180* @defgroup lavf_encoding Muxing181* @{182* Muxers take encoded data in the form of @ref AVPacket "AVPackets" and write183* it into files or other output bytestreams in the specified container format.184*185* The main API functions for muxing are avformat_write_header() for writing the186* file header, av_write_frame() / av_interleaved_write_frame() for writing the187* packets and av_write_trailer() for finalizing the file.188*189* At the beginning of the muxing process, the caller must first call190* avformat_alloc_context() to create a muxing context. The caller then sets up191* the muxer by filling the various fields in this context:192*193* - The @ref AVFormatContext.oformat "oformat" field must be set to select the194* muxer that will be used.195* - Unless the format is of the AVFMT_NOFILE type, the @ref AVFormatContext.pb196* "pb" field must be set to an opened IO context, either returned from197* avio_open2() or a custom one.198* - Unless the format is of the AVFMT_NOSTREAMS type, at least one stream must199* be created with the avformat_new_stream() function. The caller should fill200* the @ref AVStream.codecpar "stream codec parameters" information, such as the201* codec @ref AVCodecParameters.codec_type "type", @ref AVCodecParameters.codec_id202* "id" and other parameters (e.g. width / height, the pixel or sample format,203* etc.) as known. The @ref AVStream.time_base "stream timebase" should204* be set to the timebase that the caller desires to use for this stream (note205* that the timebase actually used by the muxer can be different, as will be206* described later).207* - It is advised to manually initialize only the relevant fields in208* AVCodecParameters, rather than using @ref avcodec_parameters_copy() during209* remuxing: there is no guarantee that the codec context values remain valid210* for both input and output format contexts.211* - The caller may fill in additional information, such as @ref212* AVFormatContext.metadata "global" or @ref AVStream.metadata "per-stream"213* metadata, @ref AVFormatContext.chapters "chapters", @ref214* AVFormatContext.programs "programs", etc. as described in the215* AVFormatContext documentation. Whether such information will actually be216* stored in the output depends on what the container format and the muxer217* support.218*219* When the muxing context is fully set up, the caller must call220* avformat_write_header() to initialize the muxer internals and write the file221* header. Whether anything actually is written to the IO context at this step222* depends on the muxer, but this function must always be called. Any muxer223* private options must be passed in the options parameter to this function.224*225* The data is then sent to the muxer by repeatedly calling av_write_frame() or226* av_interleaved_write_frame() (consult those functions' documentation for227* discussion on the difference between them; only one of them may be used with228* a single muxing context, they should not be mixed). Do note that the timing229* information on the packets sent to the muxer must be in the corresponding230* AVStream's timebase. That timebase is set by the muxer (in the231* avformat_write_header() step) and may be different from the timebase232* requested by the caller.233*234* Once all the data has been written, the caller must call av_write_trailer()235* to flush any buffered packets and finalize the output file, then close the IO236* context (if any) and finally free the muxing context with237* avformat_free_context().238* @}239*240* @defgroup lavf_io I/O Read/Write241* @{242* @section lavf_io_dirlist Directory listing243* The directory listing API makes it possible to list files on remote servers.244*245* Some of possible use cases:246* - an "open file" dialog to choose files from a remote location,247* - a recursive media finder providing a player with an ability to play all248* files from a given directory.249*250* @subsection lavf_io_dirlist_open Opening a directory251* At first, a directory needs to be opened by calling avio_open_dir()252* supplied with a URL and, optionally, ::AVDictionary containing253* protocol-specific parameters. The function returns zero or positive254* integer and allocates AVIODirContext on success.255*256* @code257* AVIODirContext *ctx = NULL;258* if (avio_open_dir(&ctx, "smb://example.com/some_dir", NULL) < 0) {259* fprintf(stderr, "Cannot open directory.\n");260* abort();261* }262* @endcode263*264* This code tries to open a sample directory using smb protocol without265* any additional parameters.266*267* @subsection lavf_io_dirlist_read Reading entries268* Each directory's entry (i.e. file, another directory, anything else269* within ::AVIODirEntryType) is represented by AVIODirEntry.270* Reading consecutive entries from an opened AVIODirContext is done by271* repeatedly calling avio_read_dir() on it. Each call returns zero or272* positive integer if successful. Reading can be stopped right after the273* NULL entry has been read -- it means there are no entries left to be274* read. The following code reads all entries from a directory associated275* with ctx and prints their names to standard output.276* @code277* AVIODirEntry *entry = NULL;278* for (;;) {279* if (avio_read_dir(ctx, &entry) < 0) {280* fprintf(stderr, "Cannot list directory.\n");281* abort();282* }283* if (!entry)284* break;285* printf("%s\n", entry->name);286* avio_free_directory_entry(&entry);287* }288* @endcode289* @}290*291* @defgroup lavf_codec Demuxers292* @{293* @defgroup lavf_codec_native Native Demuxers294* @{295* @}296* @defgroup lavf_codec_wrappers External library wrappers297* @{298* @}299* @}300* @defgroup lavf_protos I/O Protocols301* @{302* @}303* @defgroup lavf_internal Internal304* @{305* @}306* @}307*/308309#include <stdio.h> /* FILE */310311#include "libavcodec/codec_par.h"312#include "libavcodec/defs.h"313#include "libavcodec/packet.h"314315#include "libavutil/dict.h"316#include "libavutil/log.h"317318#include "avio.h"319#include "libavformat/version_major.h"320#ifndef HAVE_AV_CONFIG_H321/* When included as part of the ffmpeg build, only include the major version322* to avoid unnecessary rebuilds. When included externally, keep including323* the full version information. */324#include "libavformat/version.h"325326#include "libavutil/frame.h"327#include "libavcodec/codec.h"328#endif329330struct AVFormatContext;331struct AVFrame;332333/**334* @defgroup metadata_api Public Metadata API335* @{336* @ingroup libavf337* The metadata API allows libavformat to export metadata tags to a client338* application when demuxing. Conversely it allows a client application to339* set metadata when muxing.340*341* Metadata is exported or set as pairs of key/value strings in the 'metadata'342* fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs343* using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,344* metadata is assumed to be UTF-8 encoded Unicode. Note that metadata345* exported by demuxers isn't checked to be valid UTF-8 in most cases.346*347* Important concepts to keep in mind:348* - Keys are unique; there can never be 2 tags with the same key. This is349* also meant semantically, i.e., a demuxer should not knowingly produce350* several keys that are literally different but semantically identical.351* E.g., key=Author5, key=Author6. In this example, all authors must be352* placed in the same tag.353* - Metadata is flat, not hierarchical; there are no subtags. If you354* want to store, e.g., the email address of the child of producer Alice355* and actor Bob, that could have key=alice_and_bobs_childs_email_address.356* - Several modifiers can be applied to the tag name. This is done by357* appending a dash character ('-') and the modifier name in the order358* they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.359* - language -- a tag whose value is localized for a particular language360* is appended with the ISO 639-2/B 3-letter language code.361* For example: Author-ger=Michael, Author-eng=Mike362* The original/default language is in the unqualified "Author" tag.363* A demuxer should set a default if it sets any translated tag.364* - sorting -- a modified version of a tag that should be used for365* sorting will have '-sort' appended. E.g. artist="The Beatles",366* artist-sort="Beatles, The".367* - Some protocols and demuxers support metadata updates. After a successful368* call to av_read_frame(), AVFormatContext.event_flags or AVStream.event_flags369* will be updated to indicate if metadata changed. In order to detect metadata370* changes on a stream, you need to loop through all streams in the AVFormatContext371* and check their individual event_flags.372*373* - Demuxers attempt to export metadata in a generic format, however tags374* with no generic equivalents are left as they are stored in the container.375* Follows a list of generic tag names:376*377@verbatim378album -- name of the set this work belongs to379album_artist -- main creator of the set/album, if different from artist.380e.g. "Various Artists" for compilation albums.381artist -- main creator of the work382comment -- any additional description of the file.383composer -- who composed the work, if different from artist.384copyright -- name of copyright holder.385creation_time-- date when the file was created, preferably in ISO 8601.386date -- date when the work was created, preferably in ISO 8601.387disc -- number of a subset, e.g. disc in a multi-disc collection.388encoder -- name/settings of the software/hardware that produced the file.389encoded_by -- person/group who created the file.390filename -- original name of the file.391genre -- <self-evident>.392language -- main language in which the work is performed, preferably393in ISO 639-2 format. Multiple languages can be specified by394separating them with commas.395performer -- artist who performed the work, if different from artist.396E.g for "Also sprach Zarathustra", artist would be "Richard397Strauss" and performer "London Philharmonic Orchestra".398publisher -- name of the label/publisher.399service_name -- name of the service in broadcasting (channel name).400service_provider -- name of the service provider in broadcasting.401title -- name of the work.402track -- number of this work in the set, can be in form current/total.403variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of404@endverbatim405*406* Look in the examples section for an application example how to use the Metadata API.407*408* @}409*/410411/* packet functions */412413414/**415* Allocate and read the payload of a packet and initialize its416* fields with default values.417*418* @param s associated IO context419* @param pkt packet420* @param size desired payload size421* @return >0 (read size) if OK, AVERROR_xxx otherwise422*/423int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);424425426/**427* Read data and append it to the current content of the AVPacket.428* If pkt->size is 0 this is identical to av_get_packet.429* Note that this uses av_grow_packet and thus involves a realloc430* which is inefficient. Thus this function should only be used431* when there is no reasonable way to know (an upper bound of)432* the final size.433*434* @param s associated IO context435* @param pkt packet436* @param size amount of data to read437* @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data438* will not be lost even if an error occurs.439*/440int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);441442/*************************************************/443/* input/output formats */444445struct AVCodecTag;446447/**448* This structure contains the data a format has to probe a file.449*/450typedef struct AVProbeData {451const char *filename;452unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */453int buf_size; /**< Size of buf except extra allocated bytes */454const char *mime_type; /**< mime_type, when known. */455} AVProbeData;456457#define AVPROBE_SCORE_RETRY (AVPROBE_SCORE_MAX/4)458#define AVPROBE_SCORE_STREAM_RETRY (AVPROBE_SCORE_MAX/4-1)459460#define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension461#define AVPROBE_SCORE_MIME_BONUS 30 ///< score added for matching mime type462#define AVPROBE_SCORE_MAX 100 ///< maximum score463464#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer465466/// Demuxer will use avio_open, no opened file should be provided by the caller.467#define AVFMT_NOFILE 0x0001468#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */469/**470* The muxer/demuxer is experimental and should be used with caution.471*472* It will not be selected automatically, and must be specified explicitly.473*/474#define AVFMT_EXPERIMENTAL 0x0004475#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */476#define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */477#define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */478#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */479#define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */480#define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */481#define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */482#define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */483#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */484#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */485#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */486#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly487increasing timestamps, but they must488still be monotonic */489#define AVFMT_TS_NEGATIVE 0x40000 /**< Format allows muxing negative490timestamps. If not set the timestamp491will be shifted in av_write_frame and492av_interleaved_write_frame so they493start from 0.494The user or muxer can override this through495AVFormatContext.avoid_negative_ts496*/497498#define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */499500/**501* @addtogroup lavf_encoding502* @{503*/504typedef struct AVOutputFormat {505const char *name;506/**507* Descriptive name for the format, meant to be more human-readable508* than name. You should use the NULL_IF_CONFIG_SMALL() macro509* to define it.510*/511const char *long_name;512const char *mime_type;513const char *extensions; /**< comma-separated filename extensions */514/* output support */515enum AVCodecID audio_codec; /**< default audio codec */516enum AVCodecID video_codec; /**< default video codec */517enum AVCodecID subtitle_codec; /**< default subtitle codec */518/**519* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,520* AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,521* AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS,522* AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE523*/524int flags;525526/**527* List of supported codec_id-codec_tag pairs, ordered by "better528* choice first". The arrays are all terminated by AV_CODEC_ID_NONE.529*/530const struct AVCodecTag * const *codec_tag;531532533const AVClass *priv_class; ///< AVClass for the private context534} AVOutputFormat;535/**536* @}537*/538539/**540* @addtogroup lavf_decoding541* @{542*/543typedef struct AVInputFormat {544/**545* A comma separated list of short names for the format. New names546* may be appended with a minor bump.547*/548const char *name;549550/**551* Descriptive name for the format, meant to be more human-readable552* than name. You should use the NULL_IF_CONFIG_SMALL() macro553* to define it.554*/555const char *long_name;556557/**558* Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,559* AVFMT_NOTIMESTAMPS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,560* AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.561*/562int flags;563564/**565* If extensions are defined, then no probe is done. You should566* usually not use extension format guessing because it is not567* reliable enough568*/569const char *extensions;570571const struct AVCodecTag * const *codec_tag;572573const AVClass *priv_class; ///< AVClass for the private context574575/**576* Comma-separated list of mime types.577* It is used check for matching mime types while probing.578* @see av_probe_input_format2579*/580const char *mime_type;581} AVInputFormat;582/**583* @}584*/585586enum AVStreamParseType {587AVSTREAM_PARSE_NONE,588AVSTREAM_PARSE_FULL, /**< full parsing and repack */589AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */590AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */591AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */592AVSTREAM_PARSE_FULL_RAW, /**< full parsing and repack with timestamp and position generation by parser for raw593this assumes that each packet in the file contains no demuxer level headers and594just codec level data, otherwise position generation would fail */595};596597typedef struct AVIndexEntry {598int64_t pos;599int64_t timestamp; /**<600* Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are available601* when seeking to this entry. That means preferable PTS on keyframe based formats.602* But demuxers can choose to store a different timestamp, if it is more convenient for the implementation or nothing better603* is known604*/605#define AVINDEX_KEYFRAME 0x0001606#define AVINDEX_DISCARD_FRAME 0x0002 /**607* Flag is used to indicate which frame should be discarded after decoding.608*/609int flags:2;610int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).611int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */612} AVIndexEntry;613614/**615* The stream should be chosen by default among other streams of the same type,616* unless the user has explicitly specified otherwise.617*/618#define AV_DISPOSITION_DEFAULT (1 << 0)619/**620* The stream is not in original language.621*622* @note AV_DISPOSITION_ORIGINAL is the inverse of this disposition. At most623* one of them should be set in properly tagged streams.624* @note This disposition may apply to any stream type, not just audio.625*/626#define AV_DISPOSITION_DUB (1 << 1)627/**628* The stream is in original language.629*630* @see the notes for AV_DISPOSITION_DUB631*/632#define AV_DISPOSITION_ORIGINAL (1 << 2)633/**634* The stream is a commentary track.635*/636#define AV_DISPOSITION_COMMENT (1 << 3)637/**638* The stream contains song lyrics.639*/640#define AV_DISPOSITION_LYRICS (1 << 4)641/**642* The stream contains karaoke audio.643*/644#define AV_DISPOSITION_KARAOKE (1 << 5)645646/**647* Track should be used during playback by default.648* Useful for subtitle track that should be displayed649* even when user did not explicitly ask for subtitles.650*/651#define AV_DISPOSITION_FORCED (1 << 6)652/**653* The stream is intended for hearing impaired audiences.654*/655#define AV_DISPOSITION_HEARING_IMPAIRED (1 << 7)656/**657* The stream is intended for visually impaired audiences.658*/659#define AV_DISPOSITION_VISUAL_IMPAIRED (1 << 8)660/**661* The audio stream contains music and sound effects without voice.662*/663#define AV_DISPOSITION_CLEAN_EFFECTS (1 << 9)664/**665* The stream is stored in the file as an attached picture/"cover art" (e.g.666* APIC frame in ID3v2). The first (usually only) packet associated with it667* will be returned among the first few packets read from the file unless668* seeking takes place. It can also be accessed at any time in669* AVStream.attached_pic.670*/671#define AV_DISPOSITION_ATTACHED_PIC (1 << 10)672/**673* The stream is sparse, and contains thumbnail images, often corresponding674* to chapter markers. Only ever used with AV_DISPOSITION_ATTACHED_PIC.675*/676#define AV_DISPOSITION_TIMED_THUMBNAILS (1 << 11)677678/**679* The stream is intended to be mixed with a spatial audio track. For example,680* it could be used for narration or stereo music, and may remain unchanged by681* listener head rotation.682*/683#define AV_DISPOSITION_NON_DIEGETIC (1 << 12)684685/**686* The subtitle stream contains captions, providing a transcription and possibly687* a translation of audio. Typically intended for hearing-impaired audiences.688*/689#define AV_DISPOSITION_CAPTIONS (1 << 16)690/**691* The subtitle stream contains a textual description of the video content.692* Typically intended for visually-impaired audiences or for the cases where the693* video cannot be seen.694*/695#define AV_DISPOSITION_DESCRIPTIONS (1 << 17)696/**697* The subtitle stream contains time-aligned metadata that is not intended to be698* directly presented to the user.699*/700#define AV_DISPOSITION_METADATA (1 << 18)701/**702* The stream is intended to be mixed with another stream before presentation.703* Used for example to signal the stream contains an image part of a HEIF grid,704* or for mix_type=0 in mpegts.705*/706#define AV_DISPOSITION_DEPENDENT (1 << 19)707/**708* The video stream contains still images.709*/710#define AV_DISPOSITION_STILL_IMAGE (1 << 20)711/**712* The video stream contains multiple layers, e.g. stereoscopic views (cf. H.264713* Annex G/H, or HEVC Annex F).714*/715#define AV_DISPOSITION_MULTILAYER (1 << 21)716717/**718* @return The AV_DISPOSITION_* flag corresponding to disp or a negative error719* code if disp does not correspond to a known stream disposition.720*/721int av_disposition_from_string(const char *disp);722723/**724* @param disposition a combination of AV_DISPOSITION_* values725* @return The string description corresponding to the lowest set bit in726* disposition. NULL when the lowest set bit does not correspond727* to a known disposition or when disposition is 0.728*/729const char *av_disposition_to_string(int disposition);730731/**732* Options for behavior on timestamp wrap detection.733*/734#define AV_PTS_WRAP_IGNORE 0 ///< ignore the wrap735#define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection736#define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection737738/**739* Stream structure.740* New fields can be added to the end with minor version bumps.741* Removal, reordering and changes to existing fields require a major742* version bump.743* sizeof(AVStream) must not be used outside libav*.744*/745typedef struct AVStream {746/**747* A class for @ref avoptions. Set on stream creation.748*/749const AVClass *av_class;750751int index; /**< stream index in AVFormatContext */752/**753* Format-specific stream ID.754* decoding: set by libavformat755* encoding: set by the user, replaced by libavformat if left unset756*/757int id;758759/**760* Codec parameters associated with this stream. Allocated and freed by761* libavformat in avformat_new_stream() and avformat_free_context()762* respectively.763*764* - demuxing: filled by libavformat on stream creation or in765* avformat_find_stream_info()766* - muxing: filled by the caller before avformat_write_header()767*/768AVCodecParameters *codecpar;769770void *priv_data;771772/**773* This is the fundamental unit of time (in seconds) in terms774* of which frame timestamps are represented.775*776* decoding: set by libavformat777* encoding: May be set by the caller before avformat_write_header() to778* provide a hint to the muxer about the desired timebase. In779* avformat_write_header(), the muxer will overwrite this field780* with the timebase that will actually be used for the timestamps781* written into the file (which may or may not be related to the782* user-provided one, depending on the format).783*/784AVRational time_base;785786/**787* Decoding: pts of the first frame of the stream in presentation order, in stream time base.788* Only set this if you are absolutely 100% sure that the value you set789* it to really is the pts of the first frame.790* This may be undefined (AV_NOPTS_VALUE).791* @note The ASF header does NOT contain a correct start_time the ASF792* demuxer must NOT set this.793*/794int64_t start_time;795796/**797* Decoding: duration of the stream, in stream time base.798* If a source file does not specify a duration, but does specify799* a bitrate, this value will be estimated from bitrate and file size.800*801* Encoding: May be set by the caller before avformat_write_header() to802* provide a hint to the muxer about the estimated duration.803*/804int64_t duration;805806int64_t nb_frames; ///< number of frames in this stream if known or 0807808/**809* Stream disposition - a combination of AV_DISPOSITION_* flags.810* - demuxing: set by libavformat when creating the stream or in811* avformat_find_stream_info().812* - muxing: may be set by the caller before avformat_write_header().813*/814int disposition;815816enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.817818/**819* sample aspect ratio (0 if unknown)820* - encoding: Set by user.821* - decoding: Set by libavformat.822*/823AVRational sample_aspect_ratio;824825AVDictionary *metadata;826827/**828* Average framerate829*830* - demuxing: May be set by libavformat when creating the stream or in831* avformat_find_stream_info().832* - muxing: May be set by the caller before avformat_write_header().833*/834AVRational avg_frame_rate;835836/**837* For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet838* will contain the attached picture.839*840* decoding: set by libavformat, must not be modified by the caller.841* encoding: unused842*/843AVPacket attached_pic;844845/**846* Flags indicating events happening on the stream, a combination of847* AVSTREAM_EVENT_FLAG_*.848*849* - demuxing: may be set by the demuxer in avformat_open_input(),850* avformat_find_stream_info() and av_read_frame(). Flags must be cleared851* by the user once the event has been handled.852* - muxing: may be set by the user after avformat_write_header(). to853* indicate a user-triggered event. The muxer will clear the flags for854* events it has handled in av_[interleaved]_write_frame().855*/856int event_flags;857/**858* - demuxing: the demuxer read new metadata from the file and updated859* AVStream.metadata accordingly860* - muxing: the user updated AVStream.metadata and wishes the muxer to write861* it into the file862*/863#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001864/**865* - demuxing: new packets for this stream were read from the file. This866* event is informational only and does not guarantee that new packets867* for this stream will necessarily be returned from av_read_frame().868*/869#define AVSTREAM_EVENT_FLAG_NEW_PACKETS (1 << 1)870871/**872* Real base framerate of the stream.873* This is the lowest framerate with which all timestamps can be874* represented accurately (it is the least common multiple of all875* framerates in the stream). Note, this value is just a guess!876* For example, if the time base is 1/90000 and all frames have either877* approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.878*/879AVRational r_frame_rate;880881/**882* Number of bits in timestamps. Used for wrapping control.883*884* - demuxing: set by libavformat885* - muxing: set by libavformat886*887*/888int pts_wrap_bits;889} AVStream;890891/**892* AVStreamGroupTileGrid holds information on how to combine several893* independent images on a single canvas for presentation.894*895* The output should be a @ref AVStreamGroupTileGrid.background "background"896* colored @ref AVStreamGroupTileGrid.coded_width "coded_width" x897* @ref AVStreamGroupTileGrid.coded_height "coded_height" canvas where a898* @ref AVStreamGroupTileGrid.nb_tiles "nb_tiles" amount of tiles are placed in899* the order they appear in the @ref AVStreamGroupTileGrid.offsets "offsets"900* array, at the exact offset described for them. In particular, if two or more901* tiles overlap, the image with higher index in the902* @ref AVStreamGroupTileGrid.offsets "offsets" array takes priority.903* Note that a single image may be used multiple times, i.e. multiple entries904* in @ref AVStreamGroupTileGrid.offsets "offsets" may have the same value of905* idx.906*907* The following is an example of a simple grid with 3 rows and 4 columns:908*909* +---+---+---+---+910* | 0 | 1 | 2 | 3 |911* +---+---+---+---+912* | 4 | 5 | 6 | 7 |913* +---+---+---+---+914* | 8 | 9 |10 |11 |915* +---+---+---+---+916*917* Assuming all tiles have a dimension of 512x512, the918* @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of919* the first @ref AVStreamGroup.streams "stream" in the group is "0,0", the920* @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of921* the second @ref AVStreamGroup.streams "stream" in the group is "512,0", the922* @ref AVStreamGroupTileGrid.offsets "offset" of the topleft pixel of923* the fifth @ref AVStreamGroup.streams "stream" in the group is "0,512", the924* @ref AVStreamGroupTileGrid.offsets "offset", of the topleft pixel of925* the sixth @ref AVStreamGroup.streams "stream" in the group is "512,512",926* etc.927*928* The following is an example of a canvas with overlapping tiles:929*930* +-----------+931* | %%%%% |932* |***%%3%%@@@|933* |**0%%%%%2@@|934* |***##1@@@@@|935* | ##### |936* +-----------+937*938* Assuming a canvas with size 1024x1024 and all tiles with a dimension of939* 512x512, a possible @ref AVStreamGroupTileGrid.offsets "offset" for the940* topleft pixel of the first @ref AVStreamGroup.streams "stream" in the group941* would be 0x256, the @ref AVStreamGroupTileGrid.offsets "offset" for the942* topleft pixel of the second @ref AVStreamGroup.streams "stream" in the group943* would be 256x512, the @ref AVStreamGroupTileGrid.offsets "offset" for the944* topleft pixel of the third @ref AVStreamGroup.streams "stream" in the group945* would be 512x256, and the @ref AVStreamGroupTileGrid.offsets "offset" for946* the topleft pixel of the fourth @ref AVStreamGroup.streams "stream" in the947* group would be 256x0.948*949* sizeof(AVStreamGroupTileGrid) is not a part of the ABI and may only be950* allocated by avformat_stream_group_create().951*/952typedef struct AVStreamGroupTileGrid {953const AVClass *av_class;954955/**956* Amount of tiles in the grid.957*958* Must be > 0.959*/960unsigned int nb_tiles;961962/**963* Width of the canvas.964*965* Must be > 0.966*/967int coded_width;968/**969* Width of the canvas.970*971* Must be > 0.972*/973int coded_height;974975/**976* An @ref nb_tiles sized array of offsets in pixels from the topleft edge977* of the canvas, indicating where each stream should be placed.978* It must be allocated with the av_malloc() family of functions.979*980* - demuxing: set by libavformat, must not be modified by the caller.981* - muxing: set by the caller before avformat_write_header().982*983* Freed by libavformat in avformat_free_context().984*/985struct {986/**987* Index of the stream in the group this tile references.988*989* Must be < @ref AVStreamGroup.nb_streams "nb_streams".990*/991unsigned int idx;992/**993* Offset in pixels from the left edge of the canvas where the tile994* should be placed.995*/996int horizontal;997/**998* Offset in pixels from the top edge of the canvas where the tile999* should be placed.1000*/1001int vertical;1002} *offsets;10031004/**1005* The pixel value per channel in RGBA format used if no pixel of any tile1006* is located at a particular pixel location.1007*1008* @see av_image_fill_color().1009* @see av_parse_color().1010*/1011uint8_t background[4];10121013/**1014* Offset in pixels from the left edge of the canvas where the actual image1015* meant for presentation starts.1016*1017* This field must be >= 0 and < @ref coded_width.1018*/1019int horizontal_offset;1020/**1021* Offset in pixels from the top edge of the canvas where the actual image1022* meant for presentation starts.1023*1024* This field must be >= 0 and < @ref coded_height.1025*/1026int vertical_offset;10271028/**1029* Width of the final image for presentation.1030*1031* Must be > 0 and <= (@ref coded_width - @ref horizontal_offset).1032* When it's not equal to (@ref coded_width - @ref horizontal_offset), the1033* result of (@ref coded_width - width - @ref horizontal_offset) is the1034* amount amount of pixels to be cropped from the right edge of the1035* final image before presentation.1036*/1037int width;1038/**1039* Height of the final image for presentation.1040*1041* Must be > 0 and <= (@ref coded_height - @ref vertical_offset).1042* When it's not equal to (@ref coded_height - @ref vertical_offset), the1043* result of (@ref coded_height - height - @ref vertical_offset) is the1044* amount amount of pixels to be cropped from the bottom edge of the1045* final image before presentation.1046*/1047int height;10481049/**1050* Additional data associated with the grid.1051*1052* Should be allocated with av_packet_side_data_new() or1053* av_packet_side_data_add(), and will be freed by avformat_free_context().1054*/1055AVPacketSideData *coded_side_data;10561057/**1058* Amount of entries in @ref coded_side_data.1059*/1060int nb_coded_side_data;1061} AVStreamGroupTileGrid;10621063/**1064* AVStreamGroupLCEVC is meant to define the relation between video streams1065* and a data stream containing LCEVC enhancement layer NALUs.1066*1067* No more than one stream of @ref AVCodecParameters.codec_type "codec_type"1068* AVMEDIA_TYPE_DATA shall be present, and it must be of1069* @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC.1070*/1071typedef struct AVStreamGroupLCEVC {1072const AVClass *av_class;10731074/**1075* Index of the LCEVC data stream in AVStreamGroup.1076*/1077unsigned int lcevc_index;1078/**1079* Width of the final stream for presentation.1080*/1081int width;1082/**1083* Height of the final image for presentation.1084*/1085int height;1086} AVStreamGroupLCEVC;10871088enum AVStreamGroupParamsType {1089AV_STREAM_GROUP_PARAMS_NONE,1090AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,1091AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,1092AV_STREAM_GROUP_PARAMS_TILE_GRID,1093AV_STREAM_GROUP_PARAMS_LCEVC,1094};10951096struct AVIAMFAudioElement;1097struct AVIAMFMixPresentation;10981099typedef struct AVStreamGroup {1100/**1101* A class for @ref avoptions. Set by avformat_stream_group_create().1102*/1103const AVClass *av_class;11041105void *priv_data;11061107/**1108* Group index in AVFormatContext.1109*/1110unsigned int index;11111112/**1113* Group type-specific group ID.1114*1115* decoding: set by libavformat1116* encoding: may set by the user1117*/1118int64_t id;11191120/**1121* Group type1122*1123* decoding: set by libavformat on group creation1124* encoding: set by avformat_stream_group_create()1125*/1126enum AVStreamGroupParamsType type;11271128/**1129* Group type-specific parameters1130*/1131union {1132struct AVIAMFAudioElement *iamf_audio_element;1133struct AVIAMFMixPresentation *iamf_mix_presentation;1134struct AVStreamGroupTileGrid *tile_grid;1135struct AVStreamGroupLCEVC *lcevc;1136} params;11371138/**1139* Metadata that applies to the whole group.1140*1141* - demuxing: set by libavformat on group creation1142* - muxing: may be set by the caller before avformat_write_header()1143*1144* Freed by libavformat in avformat_free_context().1145*/1146AVDictionary *metadata;11471148/**1149* Number of elements in AVStreamGroup.streams.1150*1151* Set by avformat_stream_group_add_stream() must not be modified by any other code.1152*/1153unsigned int nb_streams;11541155/**1156* A list of streams in the group. New entries are created with1157* avformat_stream_group_add_stream().1158*1159* - demuxing: entries are created by libavformat on group creation.1160* If AVFMTCTX_NOHEADER is set in ctx_flags, then new entries may also1161* appear in av_read_frame().1162* - muxing: entries are created by the user before avformat_write_header().1163*1164* Freed by libavformat in avformat_free_context().1165*/1166AVStream **streams;11671168/**1169* Stream group disposition - a combination of AV_DISPOSITION_* flags.1170* This field currently applies to all defined AVStreamGroupParamsType.1171*1172* - demuxing: set by libavformat when creating the group or in1173* avformat_find_stream_info().1174* - muxing: may be set by the caller before avformat_write_header().1175*/1176int disposition;1177} AVStreamGroup;11781179struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);11801181#define AV_PROGRAM_RUNNING 111821183/**1184* New fields can be added to the end with minor version bumps.1185* Removal, reordering and changes to existing fields require a major1186* version bump.1187* sizeof(AVProgram) must not be used outside libav*.1188*/1189typedef struct AVProgram {1190int id;1191int flags;1192enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller1193unsigned int *stream_index;1194unsigned int nb_stream_indexes;1195AVDictionary *metadata;11961197int program_num;1198int pmt_pid;1199int pcr_pid;1200int pmt_version;12011202/*****************************************************************1203* All fields below this line are not part of the public API. They1204* may not be used outside of libavformat and can be changed and1205* removed at will.1206* New public fields should be added right above.1207*****************************************************************1208*/1209int64_t start_time;1210int64_t end_time;12111212int64_t pts_wrap_reference; ///< reference dts for wrap detection1213int pts_wrap_behavior; ///< behavior on wrap detection1214} AVProgram;12151216#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present1217(streams are added dynamically) */1218#define AVFMTCTX_UNSEEKABLE 0x0002 /**< signal that the stream is definitely1219not seekable, and attempts to call the1220seek function will fail. For some1221network protocols (e.g. HLS), this can1222change dynamically at runtime. */12231224typedef struct AVChapter {1225int64_t id; ///< unique ID to identify the chapter1226AVRational time_base; ///< time base in which the start/end timestamps are specified1227int64_t start, end; ///< chapter start/end time in time_base units1228AVDictionary *metadata;1229} AVChapter;123012311232/**1233* Callback used by devices to communicate with application.1234*/1235typedef int (*av_format_control_message)(struct AVFormatContext *s, int type,1236void *data, size_t data_size);12371238typedef int (*AVOpenCallback)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,1239const AVIOInterruptCB *int_cb, AVDictionary **options);12401241/**1242* The duration of a video can be estimated through various ways, and this enum can be used1243* to know how the duration was estimated.1244*/1245enum AVDurationEstimationMethod {1246AVFMT_DURATION_FROM_PTS, ///< Duration accurately estimated from PTSes1247AVFMT_DURATION_FROM_STREAM, ///< Duration estimated from a stream with a known duration1248AVFMT_DURATION_FROM_BITRATE ///< Duration estimated from bitrate (less accurate)1249};12501251/**1252* Format I/O context.1253* New fields can be added to the end with minor version bumps.1254* Removal, reordering and changes to existing fields require a major1255* version bump.1256* sizeof(AVFormatContext) must not be used outside libav*, use1257* avformat_alloc_context() to create an AVFormatContext.1258*1259* Fields can be accessed through AVOptions (av_opt*),1260* the name string used matches the associated command line parameter name and1261* can be found in libavformat/options_table.h.1262* The AVOption/command line parameter names differ in some cases from the C1263* structure field names for historic reasons or brevity.1264*/1265typedef struct AVFormatContext {1266/**1267* A class for logging and @ref avoptions. Set by avformat_alloc_context().1268* Exports (de)muxer private options if they exist.1269*/1270const AVClass *av_class;12711272/**1273* The input container format.1274*1275* Demuxing only, set by avformat_open_input().1276*/1277const struct AVInputFormat *iformat;12781279/**1280* The output container format.1281*1282* Muxing only, must be set by the caller before avformat_write_header().1283*/1284const struct AVOutputFormat *oformat;12851286/**1287* Format private data. This is an AVOptions-enabled struct1288* if and only if iformat/oformat.priv_class is not NULL.1289*1290* - muxing: set by avformat_write_header()1291* - demuxing: set by avformat_open_input()1292*/1293void *priv_data;12941295/**1296* I/O context.1297*1298* - demuxing: either set by the user before avformat_open_input() (then1299* the user must close it manually) or set by avformat_open_input().1300* - muxing: set by the user before avformat_write_header(). The caller must1301* take care of closing / freeing the IO context.1302*1303* Do NOT set this field if AVFMT_NOFILE flag is set in1304* iformat/oformat.flags. In such a case, the (de)muxer will handle1305* I/O in some other way and this field will be NULL.1306*/1307AVIOContext *pb;13081309/* stream info */1310/**1311* Flags signalling stream properties. A combination of AVFMTCTX_*.1312* Set by libavformat.1313*/1314int ctx_flags;13151316/**1317* Number of elements in AVFormatContext.streams.1318*1319* Set by avformat_new_stream(), must not be modified by any other code.1320*/1321unsigned int nb_streams;1322/**1323* A list of all streams in the file. New streams are created with1324* avformat_new_stream().1325*1326* - demuxing: streams are created by libavformat in avformat_open_input().1327* If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also1328* appear in av_read_frame().1329* - muxing: streams are created by the user before avformat_write_header().1330*1331* Freed by libavformat in avformat_free_context().1332*/1333AVStream **streams;13341335/**1336* Number of elements in AVFormatContext.stream_groups.1337*1338* Set by avformat_stream_group_create(), must not be modified by any other code.1339*/1340unsigned int nb_stream_groups;1341/**1342* A list of all stream groups in the file. New groups are created with1343* avformat_stream_group_create(), and filled with avformat_stream_group_add_stream().1344*1345* - demuxing: groups may be created by libavformat in avformat_open_input().1346* If AVFMTCTX_NOHEADER is set in ctx_flags, then new groups may also1347* appear in av_read_frame().1348* - muxing: groups may be created by the user before avformat_write_header().1349*1350* Freed by libavformat in avformat_free_context().1351*/1352AVStreamGroup **stream_groups;13531354/**1355* Number of chapters in AVChapter array.1356* When muxing, chapters are normally written in the file header,1357* so nb_chapters should normally be initialized before write_header1358* is called. Some muxers (e.g. mov and mkv) can also write chapters1359* in the trailer. To write chapters in the trailer, nb_chapters1360* must be zero when write_header is called and non-zero when1361* write_trailer is called.1362* - muxing: set by user1363* - demuxing: set by libavformat1364*/1365unsigned int nb_chapters;1366AVChapter **chapters;13671368/**1369* input or output URL. Unlike the old filename field, this field has no1370* length restriction.1371*1372* - demuxing: set by avformat_open_input(), initialized to an empty1373* string if url parameter was NULL in avformat_open_input().1374* - muxing: may be set by the caller before calling avformat_write_header()1375* (or avformat_init_output() if that is called first) to a string1376* which is freeable by av_free(). Set to an empty string if it1377* was NULL in avformat_init_output().1378*1379* Freed by libavformat in avformat_free_context().1380*/1381char *url;13821383/**1384* Position of the first frame of the component, in1385* AV_TIME_BASE fractional seconds. NEVER set this value directly:1386* It is deduced from the AVStream values.1387*1388* Demuxing only, set by libavformat.1389*/1390int64_t start_time;13911392/**1393* Duration of the stream, in AV_TIME_BASE fractional1394* seconds. Only set this value if you know none of the individual stream1395* durations and also do not set any of them. This is deduced from the1396* AVStream values if not set.1397*1398* Demuxing only, set by libavformat.1399*/1400int64_t duration;14011402/**1403* Total stream bitrate in bit/s, 0 if not1404* available. Never set it directly if the file_size and the1405* duration are known as FFmpeg can compute it automatically.1406*/1407int64_t bit_rate;14081409unsigned int packet_size;1410int max_delay;14111412/**1413* Flags modifying the (de)muxer behaviour. A combination of AVFMT_FLAG_*.1414* Set by the user before avformat_open_input() / avformat_write_header().1415*/1416int flags;1417#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.1418#define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.1419#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.1420#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS1421#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container1422#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the filling code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled1423#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible1424#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.1425#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted1426#define AVFMT_FLAG_FLUSH_PACKETS 0x0200 ///< Flush the AVIOContext every packet.1427/**1428* When muxing, try to avoid writing any random/volatile data to the output.1429* This includes any random IDs, real-time timestamps/dates, muxer version, etc.1430*1431* This flag is mainly intended for testing.1432*/1433#define AVFMT_FLAG_BITEXACT 0x04001434#define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)1435#define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats1436#define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Add bitstream filters as requested by the muxer14371438/**1439* Maximum number of bytes read from input in order to determine stream1440* properties. Used when reading the global header and in1441* avformat_find_stream_info().1442*1443* Demuxing only, set by the caller before avformat_open_input().1444*1445* @note this is \e not used for determining the \ref AVInputFormat1446* "input format"1447* @see format_probesize1448*/1449int64_t probesize;14501451/**1452* Maximum duration (in AV_TIME_BASE units) of the data read1453* from input in avformat_find_stream_info().1454* Demuxing only, set by the caller before avformat_find_stream_info().1455* Can be set to 0 to let avformat choose using a heuristic.1456*/1457int64_t max_analyze_duration;14581459const uint8_t *key;1460int keylen;14611462unsigned int nb_programs;1463AVProgram **programs;14641465/**1466* Forced video codec_id.1467* Demuxing: Set by user.1468*/1469enum AVCodecID video_codec_id;14701471/**1472* Forced audio codec_id.1473* Demuxing: Set by user.1474*/1475enum AVCodecID audio_codec_id;14761477/**1478* Forced subtitle codec_id.1479* Demuxing: Set by user.1480*/1481enum AVCodecID subtitle_codec_id;14821483/**1484* Forced Data codec_id.1485* Demuxing: Set by user.1486*/1487enum AVCodecID data_codec_id;14881489/**1490* Metadata that applies to the whole file.1491*1492* - demuxing: set by libavformat in avformat_open_input()1493* - muxing: may be set by the caller before avformat_write_header()1494*1495* Freed by libavformat in avformat_free_context().1496*/1497AVDictionary *metadata;14981499/**1500* Start time of the stream in real world time, in microseconds1501* since the Unix epoch (00:00 1st January 1970). That is, pts=0 in the1502* stream was captured at this real world time.1503* - muxing: Set by the caller before avformat_write_header(). If set to1504* either 0 or AV_NOPTS_VALUE, then the current wall-time will1505* be used.1506* - demuxing: Set by libavformat. AV_NOPTS_VALUE if unknown. Note that1507* the value may become known after some number of frames1508* have been received.1509*/1510int64_t start_time_realtime;15111512/**1513* The number of frames used for determining the framerate in1514* avformat_find_stream_info().1515* Demuxing only, set by the caller before avformat_find_stream_info().1516*/1517int fps_probe_size;15181519/**1520* Error recognition; higher values will detect more errors but may1521* misdetect some more or less valid parts as errors.1522* Demuxing only, set by the caller before avformat_open_input().1523*/1524int error_recognition;15251526/**1527* Custom interrupt callbacks for the I/O layer.1528*1529* demuxing: set by the user before avformat_open_input().1530* muxing: set by the user before avformat_write_header()1531* (mainly useful for AVFMT_NOFILE formats). The callback1532* should also be passed to avio_open2() if it's used to1533* open the file.1534*/1535AVIOInterruptCB interrupt_callback;15361537/**1538* Flags to enable debugging.1539*/1540int debug;1541#define FF_FDEBUG_TS 0x000115421543/**1544* The maximum number of streams.1545* - encoding: unused1546* - decoding: set by user1547*/1548int max_streams;15491550/**1551* Maximum amount of memory in bytes to use for the index of each stream.1552* If the index exceeds this size, entries will be discarded as1553* needed to maintain a smaller size. This can lead to slower or less1554* accurate seeking (depends on demuxer).1555* Demuxers for which a full in-memory index is mandatory will ignore1556* this.1557* - muxing: unused1558* - demuxing: set by user1559*/1560unsigned int max_index_size;15611562/**1563* Maximum amount of memory in bytes to use for buffering frames1564* obtained from realtime capture devices.1565*/1566unsigned int max_picture_buffer;15671568/**1569* Maximum buffering duration for interleaving.1570*1571* To ensure all the streams are interleaved correctly,1572* av_interleaved_write_frame() will wait until it has at least one packet1573* for each stream before actually writing any packets to the output file.1574* When some streams are "sparse" (i.e. there are large gaps between1575* successive packets), this can result in excessive buffering.1576*1577* This field specifies the maximum difference between the timestamps of the1578* first and the last packet in the muxing queue, above which libavformat1579* will output a packet regardless of whether it has queued a packet for all1580* the streams.1581*1582* Muxing only, set by the caller before avformat_write_header().1583*/1584int64_t max_interleave_delta;15851586/**1587* Maximum number of packets to read while waiting for the first timestamp.1588* Decoding only.1589*/1590int max_ts_probe;15911592/**1593* Max chunk time in microseconds.1594* Note, not all formats support this and unpredictable things may happen if it is used when not supported.1595* - encoding: Set by user1596* - decoding: unused1597*/1598int max_chunk_duration;15991600/**1601* Max chunk size in bytes1602* Note, not all formats support this and unpredictable things may happen if it is used when not supported.1603* - encoding: Set by user1604* - decoding: unused1605*/1606int max_chunk_size;16071608/**1609* Maximum number of packets that can be probed1610* - encoding: unused1611* - decoding: set by user1612*/1613int max_probe_packets;16141615/**1616* Allow non-standard and experimental extension1617* @see AVCodecContext.strict_std_compliance1618*/1619int strict_std_compliance;16201621/**1622* Flags indicating events happening on the file, a combination of1623* AVFMT_EVENT_FLAG_*.1624*1625* - demuxing: may be set by the demuxer in avformat_open_input(),1626* avformat_find_stream_info() and av_read_frame(). Flags must be cleared1627* by the user once the event has been handled.1628* - muxing: may be set by the user after avformat_write_header() to1629* indicate a user-triggered event. The muxer will clear the flags for1630* events it has handled in av_[interleaved]_write_frame().1631*/1632int event_flags;1633/**1634* - demuxing: the demuxer read new metadata from the file and updated1635* AVFormatContext.metadata accordingly1636* - muxing: the user updated AVFormatContext.metadata and wishes the muxer to1637* write it into the file1638*/1639#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001164016411642/**1643* Avoid negative timestamps during muxing.1644* Any value of the AVFMT_AVOID_NEG_TS_* constants.1645* Note, this works better when using av_interleaved_write_frame().1646* - muxing: Set by user1647* - demuxing: unused1648*/1649int avoid_negative_ts;1650#define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format1651#define AVFMT_AVOID_NEG_TS_DISABLED 0 ///< Do not shift timestamps even when they are negative.1652#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative1653#define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 016541655/**1656* Audio preload in microseconds.1657* Note, not all formats support this and unpredictable things may happen if it is used when not supported.1658* - encoding: Set by user1659* - decoding: unused1660*/1661int audio_preload;16621663/**1664* forces the use of wallclock timestamps as pts/dts of packets1665* This has undefined results in the presence of B frames.1666* - encoding: unused1667* - decoding: Set by user1668*/1669int use_wallclock_as_timestamps;16701671/**1672* Skip duration calculation in estimate_timings_from_pts.1673* - encoding: unused1674* - decoding: set by user1675*1676* @see duration_probesize1677*/1678int skip_estimate_duration_from_pts;16791680/**1681* avio flags, used to force AVIO_FLAG_DIRECT.1682* - encoding: unused1683* - decoding: Set by user1684*/1685int avio_flags;16861687/**1688* The duration field can be estimated through various ways, and this field can be used1689* to know how the duration was estimated.1690* - encoding: unused1691* - decoding: Read by user1692*/1693enum AVDurationEstimationMethod duration_estimation_method;16941695/**1696* Skip initial bytes when opening stream1697* - encoding: unused1698* - decoding: Set by user1699*/1700int64_t skip_initial_bytes;17011702/**1703* Correct single timestamp overflows1704* - encoding: unused1705* - decoding: Set by user1706*/1707unsigned int correct_ts_overflow;17081709/**1710* Force seeking to any (also non key) frames.1711* - encoding: unused1712* - decoding: Set by user1713*/1714int seek2any;17151716/**1717* Flush the I/O context after each packet.1718* - encoding: Set by user1719* - decoding: unused1720*/1721int flush_packets;17221723/**1724* format probing score.1725* The maximal score is AVPROBE_SCORE_MAX, its set when the demuxer probes1726* the format.1727* - encoding: unused1728* - decoding: set by avformat, read by user1729*/1730int probe_score;17311732/**1733* Maximum number of bytes read from input in order to identify the1734* \ref AVInputFormat "input format". Only used when the format is not set1735* explicitly by the caller.1736*1737* Demuxing only, set by the caller before avformat_open_input().1738*1739* @see probesize1740*/1741int format_probesize;17421743/**1744* ',' separated list of allowed decoders.1745* If NULL then all are allowed1746* - encoding: unused1747* - decoding: set by user1748*/1749char *codec_whitelist;17501751/**1752* ',' separated list of allowed demuxers.1753* If NULL then all are allowed1754* - encoding: unused1755* - decoding: set by user1756*/1757char *format_whitelist;17581759/**1760* ',' separated list of allowed protocols.1761* - encoding: unused1762* - decoding: set by user1763*/1764char *protocol_whitelist;17651766/**1767* ',' separated list of disallowed protocols.1768* - encoding: unused1769* - decoding: set by user1770*/1771char *protocol_blacklist;17721773/**1774* IO repositioned flag.1775* This is set by avformat when the underlying IO context read pointer1776* is repositioned, for example when doing byte based seeking.1777* Demuxers can use the flag to detect such changes.1778*/1779int io_repositioned;17801781/**1782* Forced video codec.1783* This allows forcing a specific decoder, even when there are multiple with1784* the same codec_id.1785* Demuxing: Set by user1786*/1787const struct AVCodec *video_codec;17881789/**1790* Forced audio codec.1791* This allows forcing a specific decoder, even when there are multiple with1792* the same codec_id.1793* Demuxing: Set by user1794*/1795const struct AVCodec *audio_codec;17961797/**1798* Forced subtitle codec.1799* This allows forcing a specific decoder, even when there are multiple with1800* the same codec_id.1801* Demuxing: Set by user1802*/1803const struct AVCodec *subtitle_codec;18041805/**1806* Forced data codec.1807* This allows forcing a specific decoder, even when there are multiple with1808* the same codec_id.1809* Demuxing: Set by user1810*/1811const struct AVCodec *data_codec;18121813/**1814* Number of bytes to be written as padding in a metadata header.1815* Demuxing: Unused.1816* Muxing: Set by user.1817*/1818int metadata_header_padding;18191820/**1821* User data.1822* This is a place for some private data of the user.1823*/1824void *opaque;18251826/**1827* Callback used by devices to communicate with application.1828*/1829av_format_control_message control_message_cb;18301831/**1832* Output timestamp offset, in microseconds.1833* Muxing: set by user1834*/1835int64_t output_ts_offset;18361837/**1838* dump format separator.1839* can be ", " or "\n " or anything else1840* - muxing: Set by user.1841* - demuxing: Set by user.1842*/1843uint8_t *dump_separator;18441845/**1846* A callback for opening new IO streams.1847*1848* Whenever a muxer or a demuxer needs to open an IO stream (typically from1849* avformat_open_input() for demuxers, but for certain formats can happen at1850* other times as well), it will call this callback to obtain an IO context.1851*1852* @param s the format context1853* @param pb on success, the newly opened IO context should be returned here1854* @param url the url to open1855* @param flags a combination of AVIO_FLAG_*1856* @param options a dictionary of additional options, with the same1857* semantics as in avio_open2()1858* @return 0 on success, a negative AVERROR code on failure1859*1860* @note Certain muxers and demuxers do nesting, i.e. they open one or more1861* additional internal format contexts. Thus the AVFormatContext pointer1862* passed to this callback may be different from the one facing the caller.1863* It will, however, have the same 'opaque' field.1864*/1865int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,1866int flags, AVDictionary **options);18671868/**1869* A callback for closing the streams opened with AVFormatContext.io_open().1870*1871* @param s the format context1872* @param pb IO context to be closed and freed1873* @return 0 on success, a negative AVERROR code on failure1874*/1875int (*io_close2)(struct AVFormatContext *s, AVIOContext *pb);18761877/**1878* Maximum number of bytes read from input in order to determine stream durations1879* when using estimate_timings_from_pts in avformat_find_stream_info().1880* Demuxing only, set by the caller before avformat_find_stream_info().1881* Can be set to 0 to let avformat choose using a heuristic.1882*1883* @see skip_estimate_duration_from_pts1884*/1885int64_t duration_probesize;1886} AVFormatContext;18871888/**1889* @defgroup lavf_core Core functions1890* @ingroup libavf1891*1892* Functions for querying libavformat capabilities, allocating core structures,1893* etc.1894* @{1895*/18961897/**1898* Return the LIBAVFORMAT_VERSION_INT constant.1899*/1900unsigned avformat_version(void);19011902/**1903* Return the libavformat build-time configuration.1904*/1905const char *avformat_configuration(void);19061907/**1908* Return the libavformat license.1909*/1910const char *avformat_license(void);19111912/**1913* Do global initialization of network libraries. This is optional,1914* and not recommended anymore.1915*1916* This functions only exists to work around thread-safety issues1917* with older GnuTLS or OpenSSL libraries. If libavformat is linked1918* to newer versions of those libraries, or if you do not use them,1919* calling this function is unnecessary. Otherwise, you need to call1920* this function before any other threads using them are started.1921*1922* This function will be deprecated once support for older GnuTLS and1923* OpenSSL libraries is removed, and this function has no purpose1924* anymore.1925*/1926int avformat_network_init(void);19271928/**1929* Undo the initialization done by avformat_network_init. Call it only1930* once for each time you called avformat_network_init.1931*/1932int avformat_network_deinit(void);19331934/**1935* Iterate over all registered muxers.1936*1937* @param opaque a pointer where libavformat will store the iteration state. Must1938* point to NULL to start the iteration.1939*1940* @return the next registered muxer or NULL when the iteration is1941* finished1942*/1943const AVOutputFormat *av_muxer_iterate(void **opaque);19441945/**1946* Iterate over all registered demuxers.1947*1948* @param opaque a pointer where libavformat will store the iteration state.1949* Must point to NULL to start the iteration.1950*1951* @return the next registered demuxer or NULL when the iteration is1952* finished1953*/1954const AVInputFormat *av_demuxer_iterate(void **opaque);19551956/**1957* Allocate an AVFormatContext.1958* avformat_free_context() can be used to free the context and everything1959* allocated by the framework within it.1960*/1961AVFormatContext *avformat_alloc_context(void);19621963/**1964* Free an AVFormatContext and all its streams.1965* @param s context to free1966*/1967void avformat_free_context(AVFormatContext *s);19681969/**1970* Get the AVClass for AVFormatContext. It can be used in combination with1971* AV_OPT_SEARCH_FAKE_OBJ for examining options.1972*1973* @see av_opt_find().1974*/1975const AVClass *avformat_get_class(void);19761977/**1978* Get the AVClass for AVStream. It can be used in combination with1979* AV_OPT_SEARCH_FAKE_OBJ for examining options.1980*1981* @see av_opt_find().1982*/1983const AVClass *av_stream_get_class(void);19841985/**1986* Get the AVClass for AVStreamGroup. It can be used in combination with1987* AV_OPT_SEARCH_FAKE_OBJ for examining options.1988*1989* @see av_opt_find().1990*/1991const AVClass *av_stream_group_get_class(void);19921993/**1994* @return a string identifying the stream group type, or NULL if unknown1995*/1996const char *avformat_stream_group_name(enum AVStreamGroupParamsType type);19971998/**1999* Add a new empty stream group to a media file.2000*2001* When demuxing, it may be called by the demuxer in read_header(). If the2002* flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also2003* be called in read_packet().2004*2005* When muxing, may be called by the user before avformat_write_header().2006*2007* User is required to call avformat_free_context() to clean up the allocation2008* by avformat_stream_group_create().2009*2010* New streams can be added to the group with avformat_stream_group_add_stream().2011*2012* @param s media file handle2013*2014* @return newly created group or NULL on error.2015* @see avformat_new_stream, avformat_stream_group_add_stream.2016*/2017AVStreamGroup *avformat_stream_group_create(AVFormatContext *s,2018enum AVStreamGroupParamsType type,2019AVDictionary **options);20202021/**2022* Add a new stream to a media file.2023*2024* When demuxing, it is called by the demuxer in read_header(). If the2025* flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also2026* be called in read_packet().2027*2028* When muxing, should be called by the user before avformat_write_header().2029*2030* User is required to call avformat_free_context() to clean up the allocation2031* by avformat_new_stream().2032*2033* @param s media file handle2034* @param c unused, does nothing2035*2036* @return newly created stream or NULL on error.2037*/2038AVStream *avformat_new_stream(AVFormatContext *s, const struct AVCodec *c);20392040/**2041* Add an already allocated stream to a stream group.2042*2043* When demuxing, it may be called by the demuxer in read_header(). If the2044* flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also2045* be called in read_packet().2046*2047* When muxing, may be called by the user before avformat_write_header() after2048* having allocated a new group with avformat_stream_group_create() and stream with2049* avformat_new_stream().2050*2051* User is required to call avformat_free_context() to clean up the allocation2052* by avformat_stream_group_add_stream().2053*2054* @param stg stream group belonging to a media file.2055* @param st stream in the media file to add to the group.2056*2057* @retval 0 success2058* @retval AVERROR(EEXIST) the stream was already in the group2059* @retval "another negative error code" legitimate errors2060*2061* @see avformat_new_stream, avformat_stream_group_create.2062*/2063int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st);20642065AVProgram *av_new_program(AVFormatContext *s, int id);20662067/**2068* @}2069*/207020712072/**2073* Allocate an AVFormatContext for an output format.2074* avformat_free_context() can be used to free the context and2075* everything allocated by the framework within it.2076*2077* @param ctx pointee is set to the created format context,2078* or to NULL in case of failure2079* @param oformat format to use for allocating the context, if NULL2080* format_name and filename are used instead2081* @param format_name the name of output format to use for allocating the2082* context, if NULL filename is used instead2083* @param filename the name of the filename to use for allocating the2084* context, may be NULL2085*2086* @return >= 0 in case of success, a negative AVERROR code in case of2087* failure2088*/2089int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat,2090const char *format_name, const char *filename);20912092/**2093* @addtogroup lavf_decoding2094* @{2095*/20962097/**2098* Find AVInputFormat based on the short name of the input format.2099*/2100const AVInputFormat *av_find_input_format(const char *short_name);21012102/**2103* Guess the file format.2104*2105* @param pd data to be probed2106* @param is_opened Whether the file is already opened; determines whether2107* demuxers with or without AVFMT_NOFILE are probed.2108*/2109const AVInputFormat *av_probe_input_format(const AVProbeData *pd, int is_opened);21102111/**2112* Guess the file format.2113*2114* @param pd data to be probed2115* @param is_opened Whether the file is already opened; determines whether2116* demuxers with or without AVFMT_NOFILE are probed.2117* @param score_max A probe score larger that this is required to accept a2118* detection, the variable is set to the actual detection2119* score afterwards.2120* If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended2121* to retry with a larger probe buffer.2122*/2123const AVInputFormat *av_probe_input_format2(const AVProbeData *pd,2124int is_opened, int *score_max);21252126/**2127* Guess the file format.2128*2129* @param is_opened Whether the file is already opened; determines whether2130* demuxers with or without AVFMT_NOFILE are probed.2131* @param score_ret The score of the best detection.2132*/2133const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,2134int is_opened, int *score_ret);21352136/**2137* Probe a bytestream to determine the input format. Each time a probe returns2138* with a score that is too low, the probe buffer size is increased and another2139* attempt is made. When the maximum probe size is reached, the input format2140* with the highest score is returned.2141*2142* @param pb the bytestream to probe2143* @param fmt the input format is put here2144* @param url the url of the stream2145* @param logctx the log context2146* @param offset the offset within the bytestream to probe from2147* @param max_probe_size the maximum probe buffer size (zero for default)2148*2149* @return the score in case of success, a negative value corresponding to an2150* the maximal score is AVPROBE_SCORE_MAX2151* AVERROR code otherwise2152*/2153int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,2154const char *url, void *logctx,2155unsigned int offset, unsigned int max_probe_size);21562157/**2158* Like av_probe_input_buffer2() but returns 0 on success2159*/2160int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt,2161const char *url, void *logctx,2162unsigned int offset, unsigned int max_probe_size);21632164/**2165* Open an input stream and read the header. The codecs are not opened.2166* The stream must be closed with avformat_close_input().2167*2168* @param ps Pointer to user-supplied AVFormatContext (allocated by2169* avformat_alloc_context). May be a pointer to NULL, in2170* which case an AVFormatContext is allocated by this2171* function and written into ps.2172* Note that a user-supplied AVFormatContext will be freed2173* on failure and its pointer set to NULL.2174* @param url URL of the stream to open.2175* @param fmt If non-NULL, this parameter forces a specific input format.2176* Otherwise the format is autodetected.2177* @param options A dictionary filled with AVFormatContext and demuxer-private2178* options.2179* On return this parameter will be destroyed and replaced with2180* a dict containing options that were not found. May be NULL.2181*2182* @return 0 on success; on failure: frees ps, sets its pointer to NULL,2183* and returns a negative AVERROR.2184*2185* @note If you want to use custom IO, preallocate the format context and set its pb field.2186*/2187int avformat_open_input(AVFormatContext **ps, const char *url,2188const AVInputFormat *fmt, AVDictionary **options);21892190/**2191* Read packets of a media file to get stream information. This2192* is useful for file formats with no headers such as MPEG. This2193* function also computes the real framerate in case of MPEG-2 repeat2194* frame mode.2195* The logical file position is not changed by this function;2196* examined packets may be buffered for later processing.2197*2198* @param ic media file handle2199* @param options If non-NULL, an ic.nb_streams long array of pointers to2200* dictionaries, where i-th member contains options for2201* codec corresponding to i-th stream.2202* On return each dictionary will be filled with options that were not found.2203* @return >=0 if OK, AVERROR_xxx on error2204*2205* @note this function isn't guaranteed to open all the codecs, so2206* options being non-empty at return is a perfectly normal behavior.2207*2208* @todo Let the user decide somehow what information is needed so that2209* we do not waste time getting stuff the user does not need.2210*/2211int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);22122213/**2214* Find the programs which belong to a given stream.2215*2216* @param ic media file handle2217* @param last the last found program, the search will start after this2218* program, or from the beginning if it is NULL2219* @param s stream index2220*2221* @return the next program which belongs to s, NULL if no program is found or2222* the last program is not among the programs of ic.2223*/2224AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s);22252226void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx);22272228/**2229* Find the "best" stream in the file.2230* The best stream is determined according to various heuristics as the most2231* likely to be what the user expects.2232* If the decoder parameter is non-NULL, av_find_best_stream will find the2233* default decoder for the stream's codec; streams for which no decoder can2234* be found are ignored.2235*2236* @param ic media file handle2237* @param type stream type: video, audio, subtitles, etc.2238* @param wanted_stream_nb user-requested stream number,2239* or -1 for automatic selection2240* @param related_stream try to find a stream related (eg. in the same2241* program) to this one, or -1 if none2242* @param decoder_ret if non-NULL, returns the decoder for the2243* selected stream2244* @param flags flags; none are currently defined2245*2246* @return the non-negative stream number in case of success,2247* AVERROR_STREAM_NOT_FOUND if no stream with the requested type2248* could be found,2249* AVERROR_DECODER_NOT_FOUND if streams were found but no decoder2250*2251* @note If av_find_best_stream returns successfully and decoder_ret is not2252* NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.2253*/2254int av_find_best_stream(AVFormatContext *ic,2255enum AVMediaType type,2256int wanted_stream_nb,2257int related_stream,2258const struct AVCodec **decoder_ret,2259int flags);22602261/**2262* Return the next frame of a stream.2263* This function returns what is stored in the file, and does not validate2264* that what is there are valid frames for the decoder. It will split what is2265* stored in the file into frames and return one for each call. It will not2266* omit invalid data between valid frames so as to give the decoder the maximum2267* information possible for decoding.2268*2269* On success, the returned packet is reference-counted (pkt->buf is set) and2270* valid indefinitely. The packet must be freed with av_packet_unref() when2271* it is no longer needed. For video, the packet contains exactly one frame.2272* For audio, it contains an integer number of frames if each frame has2273* a known fixed size (e.g. PCM or ADPCM data). If the audio frames have2274* a variable size (e.g. MPEG audio), then it contains one frame.2275*2276* pkt->pts, pkt->dts and pkt->duration are always set to correct2277* values in AVStream.time_base units (and guessed if the format cannot2278* provide them). pkt->pts can be AV_NOPTS_VALUE if the video format2279* has B-frames, so it is better to rely on pkt->dts if you do not2280* decompress the payload.2281*2282* @return 0 if OK, < 0 on error or end of file. On error, pkt will be blank2283* (as if it came from av_packet_alloc()).2284*2285* @note pkt will be initialized, so it may be uninitialized, but it must not2286* contain data that needs to be freed.2287*/2288int av_read_frame(AVFormatContext *s, AVPacket *pkt);22892290/**2291* Seek to the keyframe at timestamp.2292* 'timestamp' in 'stream_index'.2293*2294* @param s media file handle2295* @param stream_index If stream_index is (-1), a default stream is selected,2296* and timestamp is automatically converted from2297* AV_TIME_BASE units to the stream specific time_base.2298* @param timestamp Timestamp in AVStream.time_base units or, if no stream2299* is specified, in AV_TIME_BASE units.2300* @param flags flags which select direction and seeking mode2301*2302* @return >= 0 on success2303*/2304int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,2305int flags);23062307/**2308* Seek to timestamp ts.2309* Seeking will be done so that the point from which all active streams2310* can be presented successfully will be closest to ts and within min/max_ts.2311* Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.2312*2313* If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and2314* are the file position (this may not be supported by all demuxers).2315* If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames2316* in the stream with stream_index (this may not be supported by all demuxers).2317* Otherwise all timestamps are in units of the stream selected by stream_index2318* or if stream_index is -1, in AV_TIME_BASE units.2319* If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as2320* keyframes (this may not be supported by all demuxers).2321* If flags contain AVSEEK_FLAG_BACKWARD, it is ignored.2322*2323* @param s media file handle2324* @param stream_index index of the stream which is used as time base reference2325* @param min_ts smallest acceptable timestamp2326* @param ts target timestamp2327* @param max_ts largest acceptable timestamp2328* @param flags flags2329* @return >=0 on success, error code otherwise2330*2331* @note This is part of the new seek API which is still under construction.2332*/2333int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);23342335/**2336* Discard all internally buffered data. This can be useful when dealing with2337* discontinuities in the byte stream. Generally works only with formats that2338* can resync. This includes headerless formats like MPEG-TS/TS but should also2339* work with NUT, Ogg and in a limited way AVI for example.2340*2341* The set of streams, the detected duration, stream parameters and codecs do2342* not change when calling this function. If you want a complete reset, it's2343* better to open a new AVFormatContext.2344*2345* This does not flush the AVIOContext (s->pb). If necessary, call2346* avio_flush(s->pb) before calling this function.2347*2348* @param s media file handle2349* @return >=0 on success, error code otherwise2350*/2351int avformat_flush(AVFormatContext *s);23522353/**2354* Start playing a network-based stream (e.g. RTSP stream) at the2355* current position.2356*/2357int av_read_play(AVFormatContext *s);23582359/**2360* Pause a network-based stream (e.g. RTSP stream).2361*2362* Use av_read_play() to resume it.2363*/2364int av_read_pause(AVFormatContext *s);23652366/**2367* Close an opened input AVFormatContext. Free it and all its contents2368* and set *s to NULL.2369*/2370void avformat_close_input(AVFormatContext **s);2371/**2372* @}2373*/23742375#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward2376#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes2377#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes2378#define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number23792380/**2381* @addtogroup lavf_encoding2382* @{2383*/23842385#define AVSTREAM_INIT_IN_WRITE_HEADER 0 ///< stream parameters initialized in avformat_write_header2386#define AVSTREAM_INIT_IN_INIT_OUTPUT 1 ///< stream parameters initialized in avformat_init_output23872388/**2389* Allocate the stream private data and write the stream header to2390* an output media file.2391*2392* @param s Media file handle, must be allocated with2393* avformat_alloc_context().2394* Its \ref AVFormatContext.oformat "oformat" field must be set2395* to the desired output format;2396* Its \ref AVFormatContext.pb "pb" field must be set to an2397* already opened ::AVIOContext.2398* @param options An ::AVDictionary filled with AVFormatContext and2399* muxer-private options.2400* On return this parameter will be destroyed and replaced with2401* a dict containing options that were not found. May be NULL.2402*2403* @retval AVSTREAM_INIT_IN_WRITE_HEADER On success, if the codec had not already been2404* fully initialized in avformat_init_output().2405* @retval AVSTREAM_INIT_IN_INIT_OUTPUT On success, if the codec had already been fully2406* initialized in avformat_init_output().2407* @retval AVERROR A negative AVERROR on failure.2408*2409* @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_init_output.2410*/2411av_warn_unused_result2412int avformat_write_header(AVFormatContext *s, AVDictionary **options);24132414/**2415* Allocate the stream private data and initialize the codec, but do not write the header.2416* May optionally be used before avformat_write_header() to initialize stream parameters2417* before actually writing the header.2418* If using this function, do not pass the same options to avformat_write_header().2419*2420* @param s Media file handle, must be allocated with2421* avformat_alloc_context().2422* Its \ref AVFormatContext.oformat "oformat" field must be set2423* to the desired output format;2424* Its \ref AVFormatContext.pb "pb" field must be set to an2425* already opened ::AVIOContext.2426* @param options An ::AVDictionary filled with AVFormatContext and2427* muxer-private options.2428* On return this parameter will be destroyed and replaced with2429* a dict containing options that were not found. May be NULL.2430*2431* @retval AVSTREAM_INIT_IN_WRITE_HEADER On success, if the codec requires2432* avformat_write_header to fully initialize.2433* @retval AVSTREAM_INIT_IN_INIT_OUTPUT On success, if the codec has been fully2434* initialized.2435* @retval AVERROR Anegative AVERROR on failure.2436*2437* @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_write_header.2438*/2439av_warn_unused_result2440int avformat_init_output(AVFormatContext *s, AVDictionary **options);24412442/**2443* Write a packet to an output media file.2444*2445* This function passes the packet directly to the muxer, without any buffering2446* or reordering. The caller is responsible for correctly interleaving the2447* packets if the format requires it. Callers that want libavformat to handle2448* the interleaving should call av_interleaved_write_frame() instead of this2449* function.2450*2451* @param s media file handle2452* @param pkt The packet containing the data to be written. Note that unlike2453* av_interleaved_write_frame(), this function does not take2454* ownership of the packet passed to it (though some muxers may make2455* an internal reference to the input packet).2456* <br>2457* This parameter can be NULL (at any time, not just at the end), in2458* order to immediately flush data buffered within the muxer, for2459* muxers that buffer up data internally before writing it to the2460* output.2461* <br>2462* Packet's @ref AVPacket.stream_index "stream_index" field must be2463* set to the index of the corresponding stream in @ref2464* AVFormatContext.streams "s->streams".2465* <br>2466* The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts")2467* must be set to correct values in the stream's timebase (unless the2468* output format is flagged with the AVFMT_NOTIMESTAMPS flag, then2469* they can be set to AV_NOPTS_VALUE).2470* The dts for subsequent packets passed to this function must be strictly2471* increasing when compared in their respective timebases (unless the2472* output format is flagged with the AVFMT_TS_NONSTRICT, then they2473* merely have to be nondecreasing). @ref AVPacket.duration2474* "duration") should also be set if known.2475* @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush2476*2477* @see av_interleaved_write_frame()2478*/2479int av_write_frame(AVFormatContext *s, AVPacket *pkt);24802481/**2482* Write a packet to an output media file ensuring correct interleaving.2483*2484* This function will buffer the packets internally as needed to make sure the2485* packets in the output file are properly interleaved, usually ordered by2486* increasing dts. Callers doing their own interleaving should call2487* av_write_frame() instead of this function.2488*2489* Using this function instead of av_write_frame() can give muxers advance2490* knowledge of future packets, improving e.g. the behaviour of the mp42491* muxer for VFR content in fragmenting mode.2492*2493* @param s media file handle2494* @param pkt The packet containing the data to be written.2495* <br>2496* If the packet is reference-counted, this function will take2497* ownership of this reference and unreference it later when it sees2498* fit. If the packet is not reference-counted, libavformat will2499* make a copy.2500* The returned packet will be blank (as if returned from2501* av_packet_alloc()), even on error.2502* <br>2503* This parameter can be NULL (at any time, not just at the end), to2504* flush the interleaving queues.2505* <br>2506* Packet's @ref AVPacket.stream_index "stream_index" field must be2507* set to the index of the corresponding stream in @ref2508* AVFormatContext.streams "s->streams".2509* <br>2510* The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts")2511* must be set to correct values in the stream's timebase (unless the2512* output format is flagged with the AVFMT_NOTIMESTAMPS flag, then2513* they can be set to AV_NOPTS_VALUE).2514* The dts for subsequent packets in one stream must be strictly2515* increasing (unless the output format is flagged with the2516* AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing).2517* @ref AVPacket.duration "duration" should also be set if known.2518*2519* @return 0 on success, a negative AVERROR on error.2520*2521* @see av_write_frame(), AVFormatContext.max_interleave_delta2522*/2523int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);25242525/**2526* Write an uncoded frame to an output media file.2527*2528* The frame must be correctly interleaved according to the container2529* specification; if not, av_interleaved_write_uncoded_frame() must be used.2530*2531* See av_interleaved_write_uncoded_frame() for details.2532*/2533int av_write_uncoded_frame(AVFormatContext *s, int stream_index,2534struct AVFrame *frame);25352536/**2537* Write an uncoded frame to an output media file.2538*2539* If the muxer supports it, this function makes it possible to write an AVFrame2540* structure directly, without encoding it into a packet.2541* It is mostly useful for devices and similar special muxers that use raw2542* video or PCM data and will not serialize it into a byte stream.2543*2544* To test whether it is possible to use it with a given muxer and stream,2545* use av_write_uncoded_frame_query().2546*2547* The caller gives up ownership of the frame and must not access it2548* afterwards.2549*2550* @return >=0 for success, a negative code on error2551*/2552int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index,2553struct AVFrame *frame);25542555/**2556* Test whether a muxer supports uncoded frame.2557*2558* @return >=0 if an uncoded frame can be written to that muxer and stream,2559* <0 if not2560*/2561int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index);25622563/**2564* Write the stream trailer to an output media file and free the2565* file private data.2566*2567* May only be called after a successful call to avformat_write_header.2568*2569* @param s media file handle2570* @return 0 if OK, AVERROR_xxx on error2571*/2572int av_write_trailer(AVFormatContext *s);25732574/**2575* Return the output format in the list of registered output formats2576* which best matches the provided parameters, or return NULL if2577* there is no match.2578*2579* @param short_name if non-NULL checks if short_name matches with the2580* names of the registered formats2581* @param filename if non-NULL checks if filename terminates with the2582* extensions of the registered formats2583* @param mime_type if non-NULL checks if mime_type matches with the2584* MIME type of the registered formats2585*/2586const AVOutputFormat *av_guess_format(const char *short_name,2587const char *filename,2588const char *mime_type);25892590/**2591* Guess the codec ID based upon muxer and filename.2592*/2593enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name,2594const char *filename, const char *mime_type,2595enum AVMediaType type);25962597/**2598* Get timing information for the data currently output.2599* The exact meaning of "currently output" depends on the format.2600* It is mostly relevant for devices that have an internal buffer and/or2601* work in real time.2602* @param s media file handle2603* @param stream stream in the media file2604* @param[out] dts DTS of the last packet output for the stream, in stream2605* time_base units2606* @param[out] wall absolute time when that packet whas output,2607* in microsecond2608* @retval 0 Success2609* @retval AVERROR(ENOSYS) The format does not support it2610*2611* @note Some formats or devices may not allow to measure dts and wall2612* atomically.2613*/2614int av_get_output_timestamp(struct AVFormatContext *s, int stream,2615int64_t *dts, int64_t *wall);261626172618/**2619* @}2620*/262126222623/**2624* @defgroup lavf_misc Utility functions2625* @ingroup libavf2626* @{2627*2628* Miscellaneous utility functions related to both muxing and demuxing2629* (or neither).2630*/26312632/**2633* Send a nice hexadecimal dump of a buffer to the specified file stream.2634*2635* @param f The file stream pointer where the dump should be sent to.2636* @param buf buffer2637* @param size buffer size2638*2639* @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log22640*/2641void av_hex_dump(FILE *f, const uint8_t *buf, int size);26422643/**2644* Send a nice hexadecimal dump of a buffer to the log.2645*2646* @param avcl A pointer to an arbitrary struct of which the first field is a2647* pointer to an AVClass struct.2648* @param level The importance level of the message, lower values signifying2649* higher importance.2650* @param buf buffer2651* @param size buffer size2652*2653* @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log22654*/2655void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);26562657/**2658* Send a nice dump of a packet to the specified file stream.2659*2660* @param f The file stream pointer where the dump should be sent to.2661* @param pkt packet to dump2662* @param dump_payload True if the payload must be displayed, too.2663* @param st AVStream that the packet belongs to2664*/2665void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st);266626672668/**2669* Send a nice dump of a packet to the log.2670*2671* @param avcl A pointer to an arbitrary struct of which the first field is a2672* pointer to an AVClass struct.2673* @param level The importance level of the message, lower values signifying2674* higher importance.2675* @param pkt packet to dump2676* @param dump_payload True if the payload must be displayed, too.2677* @param st AVStream that the packet belongs to2678*/2679void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,2680const AVStream *st);26812682/**2683* Get the AVCodecID for the given codec tag tag.2684* If no codec id is found returns AV_CODEC_ID_NONE.2685*2686* @param tags list of supported codec_id-codec_tag pairs, as stored2687* in AVInputFormat.codec_tag and AVOutputFormat.codec_tag2688* @param tag codec tag to match to a codec ID2689*/2690enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);26912692/**2693* Get the codec tag for the given codec id id.2694* If no codec tag is found returns 0.2695*2696* @param tags list of supported codec_id-codec_tag pairs, as stored2697* in AVInputFormat.codec_tag and AVOutputFormat.codec_tag2698* @param id codec ID to match to a codec tag2699*/2700unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);27012702/**2703* Get the codec tag for the given codec id.2704*2705* @param tags list of supported codec_id - codec_tag pairs, as stored2706* in AVInputFormat.codec_tag and AVOutputFormat.codec_tag2707* @param id codec id that should be searched for in the list2708* @param tag A pointer to the found tag2709* @return 0 if id was not found in tags, > 0 if it was found2710*/2711int av_codec_get_tag2(const struct AVCodecTag * const *tags, enum AVCodecID id,2712unsigned int *tag);27132714int av_find_default_stream_index(AVFormatContext *s);27152716/**2717* Get the index for a specific timestamp.2718*2719* @param st stream that the timestamp belongs to2720* @param timestamp timestamp to retrieve the index for2721* @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond2722* to the timestamp which is <= the requested one, if backward2723* is 0, then it will be >=2724* if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise2725* @return < 0 if no such timestamp could be found2726*/2727int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);27282729/**2730* Get the index entry count for the given AVStream.2731*2732* @param st stream2733* @return the number of index entries in the stream2734*/2735int avformat_index_get_entries_count(const AVStream *st);27362737/**2738* Get the AVIndexEntry corresponding to the given index.2739*2740* @param st Stream containing the requested AVIndexEntry.2741* @param idx The desired index.2742* @return A pointer to the requested AVIndexEntry if it exists, NULL otherwise.2743*2744* @note The pointer returned by this function is only guaranteed to be valid2745* until any function that takes the stream or the parent AVFormatContext2746* as input argument is called.2747*/2748const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);27492750/**2751* Get the AVIndexEntry corresponding to the given timestamp.2752*2753* @param st Stream containing the requested AVIndexEntry.2754* @param wanted_timestamp Timestamp to retrieve the index entry for.2755* @param flags If AVSEEK_FLAG_BACKWARD then the returned entry will correspond2756* to the timestamp which is <= the requested one, if backward2757* is 0, then it will be >=2758* if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise.2759* @return A pointer to the requested AVIndexEntry if it exists, NULL otherwise.2760*2761* @note The pointer returned by this function is only guaranteed to be valid2762* until any function that takes the stream or the parent AVFormatContext2763* as input argument is called.2764*/2765const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st,2766int64_t wanted_timestamp,2767int flags);2768/**2769* Add an index entry into a sorted list. Update the entry if the list2770* already contains it.2771*2772* @param timestamp timestamp in the time base of the given stream2773*/2774int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,2775int size, int distance, int flags);277627772778/**2779* Split a URL string into components.2780*2781* The pointers to buffers for storing individual components may be null,2782* in order to ignore that component. Buffers for components not found are2783* set to empty strings. If the port is not found, it is set to a negative2784* value.2785*2786* @param proto the buffer for the protocol2787* @param proto_size the size of the proto buffer2788* @param authorization the buffer for the authorization2789* @param authorization_size the size of the authorization buffer2790* @param hostname the buffer for the host name2791* @param hostname_size the size of the hostname buffer2792* @param port_ptr a pointer to store the port number in2793* @param path the buffer for the path2794* @param path_size the size of the path buffer2795* @param url the URL to split2796*/2797void av_url_split(char *proto, int proto_size,2798char *authorization, int authorization_size,2799char *hostname, int hostname_size,2800int *port_ptr,2801char *path, int path_size,2802const char *url);280328042805/**2806* Print detailed information about the input or output format, such as2807* duration, bitrate, streams, container, programs, metadata, side data,2808* codec and time base.2809*2810* @param ic the context to analyze2811* @param index index of the stream to dump information about2812* @param url the URL to print, such as source or destination file2813* @param is_output Select whether the specified context is an input(0) or output(1)2814*/2815void av_dump_format(AVFormatContext *ic,2816int index,2817const char *url,2818int is_output);281928202821#define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d28222823/**2824* Return in 'buf' the path with '%d' replaced by a number.2825*2826* Also handles the '%0nd' format where 'n' is the total number2827* of digits and '%%'.2828*2829* @param buf destination buffer2830* @param buf_size destination buffer size2831* @param path numbered sequence string2832* @param number frame number2833* @param flags AV_FRAME_FILENAME_FLAGS_*2834* @return 0 if OK, -1 on format error2835*/2836int av_get_frame_filename2(char *buf, int buf_size,2837const char *path, int number, int flags);28382839int av_get_frame_filename(char *buf, int buf_size,2840const char *path, int number);28412842/**2843* Check whether filename actually is a numbered sequence generator.2844*2845* @param filename possible numbered sequence string2846* @return 1 if a valid numbered sequence string, 0 otherwise2847*/2848int av_filename_number_test(const char *filename);28492850/**2851* Generate an SDP for an RTP session.2852*2853* Note, this overwrites the id values of AVStreams in the muxer contexts2854* for getting unique dynamic payload types.2855*2856* @param ac array of AVFormatContexts describing the RTP streams. If the2857* array is composed by only one context, such context can contain2858* multiple AVStreams (one AVStream per RTP stream). Otherwise,2859* all the contexts in the array (an AVCodecContext per RTP stream)2860* must contain only one AVStream.2861* @param n_files number of AVCodecContexts contained in ac2862* @param buf buffer where the SDP will be stored (must be allocated by2863* the caller)2864* @param size the size of the buffer2865* @return 0 if OK, AVERROR_xxx on error2866*/2867int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);28682869/**2870* Return a positive value if the given filename has one of the given2871* extensions, 0 otherwise.2872*2873* @param filename file name to check against the given extensions2874* @param extensions a comma-separated list of filename extensions2875*/2876int av_match_ext(const char *filename, const char *extensions);28772878/**2879* Test if the given container can store a codec.2880*2881* @param ofmt container to check for compatibility2882* @param codec_id codec to potentially store in container2883* @param std_compliance standards compliance level, one of FF_COMPLIANCE_*2884*2885* @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.2886* A negative number if this information is not available.2887*/2888int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,2889int std_compliance);28902891/**2892* @defgroup riff_fourcc RIFF FourCCs2893* @{2894* Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are2895* meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the2896* following code:2897* @code2898* uint32_t tag = MKTAG('H', '2', '6', '4');2899* const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 };2900* enum AVCodecID id = av_codec_get_id(table, tag);2901* @endcode2902*/2903/**2904* @return the table mapping RIFF FourCCs for video to libavcodec AVCodecID.2905*/2906const struct AVCodecTag *avformat_get_riff_video_tags(void);2907/**2908* @return the table mapping RIFF FourCCs for audio to AVCodecID.2909*/2910const struct AVCodecTag *avformat_get_riff_audio_tags(void);2911/**2912* @return the table mapping MOV FourCCs for video to libavcodec AVCodecID.2913*/2914const struct AVCodecTag *avformat_get_mov_video_tags(void);2915/**2916* @return the table mapping MOV FourCCs for audio to AVCodecID.2917*/2918const struct AVCodecTag *avformat_get_mov_audio_tags(void);29192920/**2921* @}2922*/29232924/**2925* Guess the sample aspect ratio of a frame, based on both the stream and the2926* frame aspect ratio.2927*2928* Since the frame aspect ratio is set by the codec but the stream aspect ratio2929* is set by the demuxer, these two may not be equal. This function tries to2930* return the value that you should use if you would like to display the frame.2931*2932* Basic logic is to use the stream aspect ratio if it is set to something sane2933* otherwise use the frame aspect ratio. This way a container setting, which is2934* usually easy to modify can override the coded value in the frames.2935*2936* @param format the format context which the stream is part of2937* @param stream the stream which the frame is part of2938* @param frame the frame with the aspect ratio to be determined2939* @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea2940*/2941AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream,2942struct AVFrame *frame);29432944/**2945* Guess the frame rate, based on both the container and codec information.2946*2947* @param ctx the format context which the stream is part of2948* @param stream the stream which the frame is part of2949* @param frame the frame for which the frame rate should be determined, may be NULL2950* @return the guessed (valid) frame rate, 0/1 if no idea2951*/2952AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream,2953struct AVFrame *frame);29542955/**2956* Check if the stream st contained in s is matched by the stream specifier2957* spec.2958*2959* See the "stream specifiers" chapter in the documentation for the syntax2960* of spec.2961*2962* @return >0 if st is matched by spec;2963* 0 if st is not matched by spec;2964* AVERROR code if spec is invalid2965*2966* @note A stream specifier can match several streams in the format.2967*/2968int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,2969const char *spec);29702971int avformat_queue_attached_pictures(AVFormatContext *s);29722973#if FF_API_INTERNAL_TIMING2974enum AVTimebaseSource {2975AVFMT_TBCF_AUTO = -1,2976AVFMT_TBCF_DECODER,2977AVFMT_TBCF_DEMUXER,2978#if FF_API_R_FRAME_RATE2979AVFMT_TBCF_R_FRAMERATE,2980#endif2981};29822983/**2984* @deprecated do not call this function2985*/2986attribute_deprecated2987int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,2988AVStream *ost, const AVStream *ist,2989enum AVTimebaseSource copy_tb);29902991/**2992* @deprecated do not call this function2993*/2994attribute_deprecated2995AVRational av_stream_get_codec_timebase(const AVStream *st);2996#endif299729982999/**3000* @}3001*/30023003#endif /* AVFORMAT_AVFORMAT_H */300430053006