04d7f601 |
/*
* copyright (c) 2001 Fabrice Bellard
* |
b78e7197 |
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or |
04d7f601 |
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either |
b78e7197 |
* version 2.1 of the License, or (at your option) any later version. |
04d7f601 |
* |
b78e7197 |
* FFmpeg is distributed in the hope that it will be useful, |
04d7f601 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public |
b78e7197 |
* License along with FFmpeg; if not, write to the Free Software |
04d7f601 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
|
98790382 |
#ifndef AVFORMAT_AVFORMAT_H
#define AVFORMAT_AVFORMAT_H |
de6d9b64 |
|
072e3efd |
|
c97429e2 |
/** |
7ed0a77f |
* Return the LIBAVFORMAT_VERSION_INT constant. |
c97429e2 |
*/
unsigned avformat_version(void);
|
c1736936 |
/** |
49bd8e4b |
* Return the libavformat build-time configuration. |
c1736936 |
*/ |
41600690 |
const char *avformat_configuration(void); |
c1736936 |
/** |
49bd8e4b |
* Return the libavformat license. |
c1736936 |
*/ |
41600690 |
const char *avformat_license(void); |
c1736936 |
|
f71869a4 |
#include <time.h> |
67070e4f |
#include <stdio.h> /* FILE */ |
76a448ed |
#include "libavcodec/avcodec.h" |
d9f80ea2 |
#include "libavutil/dict.h" |
de6d9b64 |
#include "avio.h" |
d3058be6 |
#include "libavformat/version.h" |
de6d9b64 |
|
f610a9f2 |
struct AVFormatContext;
|
a6d18a0e |
|
f1d1ef81 |
/**
* @defgroup metadata_api Public Metadata API
* @{ |
ea29242c |
* The metadata API allows libavformat to export metadata tags to a client |
61648423 |
* application using a sequence of key/value pairs. Like all strings in FFmpeg,
* metadata must be stored as UTF-8 encoded Unicode. Note that metadata
* exported by demuxers isn't checked to be valid UTF-8 in most cases. |
ea29242c |
* Important concepts to keep in mind: |
f1d1ef81 |
* - Keys are unique; there can never be 2 tags with the same key. This is |
ea29242c |
* also meant semantically, i.e., a demuxer should not knowingly produce
* several keys that are literally different but semantically identical.
* E.g., key=Author5, key=Author6. In this example, all authors must be
* placed in the same tag. |
f1d1ef81 |
* - Metadata is flat, not hierarchical; there are no subtags. If you |
ea29242c |
* want to store, e.g., the email address of the child of producer Alice
* and actor Bob, that could have key=alice_and_bobs_childs_email_address. |
f1d1ef81 |
* - Several modifiers can be applied to the tag name. This is done by |
ca76a119 |
* appending a dash character ('-') and the modifier name in the order
* they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. |
f1d1ef81 |
* - language -- a tag whose value is localized for a particular language |
ca76a119 |
* is appended with the ISO 639-2/B 3-letter language code.
* For example: Author-ger=Michael, Author-eng=Mike
* The original/default language is in the unqualified "Author" tag.
* A demuxer should set a default if it sets any translated tag. |
f1d1ef81 |
* - sorting -- a modified version of a tag that should be used for |
ca76a119 |
* sorting will have '-sort' appended. E.g. artist="The Beatles",
* artist-sort="Beatles, The".
* |
f1d1ef81 |
* - Demuxers attempt to export metadata in a generic format, however tags |
03700d39 |
* with no generic equivalents are left as they are stored in the container.
* Follows a list of generic tag names: |
ca76a119 |
* |
f1d1ef81 |
@verbatim
album -- name of the set this work belongs to
album_artist -- main creator of the set/album, if different from artist.
e.g. "Various Artists" for compilation albums.
artist -- main creator of the work
comment -- any additional description of the file.
composer -- who composed the work, if different from artist.
copyright -- name of copyright holder.
creation_time-- date when the file was created, preferably in ISO 8601.
date -- date when the work was created, preferably in ISO 8601.
disc -- number of a subset, e.g. disc in a multi-disc collection.
encoder -- name/settings of the software/hardware that produced the file.
encoded_by -- person/group who created the file.
filename -- original name of the file.
genre -- <self-evident>.
language -- main language in which the work is performed, preferably
in ISO 639-2 format. Multiple languages can be specified by
separating them with commas.
performer -- artist who performed the work, if different from artist.
E.g for "Also sprach Zarathustra", artist would be "Richard
Strauss" and performer "London Philharmonic Orchestra".
publisher -- name of the label/publisher.
service_name -- name of the service in broadcasting (channel name).
service_provider -- name of the service provider in broadcasting.
title -- name of the work.
track -- number of this work in the set, can be in form current/total.
variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
@endverbatim
* |
c5c26543 |
* Look in the examples section for an application example how to use the Metadata API.
* |
f1d1ef81 |
* @} |
a6d18a0e |
*/
|
d9f80ea2 |
#if FF_API_OLD_METADATA2
/**
* @defgroup old_metadata Old metadata API
* The following functions are deprecated, use
* their equivalents from libavutil/dict.h instead.
* @{
*/ |
a6d18a0e |
|
d9f80ea2 |
#define AV_METADATA_MATCH_CASE AV_DICT_MATCH_CASE
#define AV_METADATA_IGNORE_SUFFIX AV_DICT_IGNORE_SUFFIX
#define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY
#define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL
#define AV_METADATA_DONT_OVERWRITE AV_DICT_DONT_OVERWRITE
typedef attribute_deprecated AVDictionary AVMetadata;
typedef attribute_deprecated AVDictionaryEntry AVMetadataTag; |
a6d18a0e |
|
f610a9f2 |
typedef struct AVMetadataConv AVMetadataConv; |
a6d18a0e |
/** |
49bd8e4b |
* Get a metadata element with matching key. |
26cc5310 |
* |
22e77e44 |
* @param prev Set to the previous matching element to find the next. |
66b6c745 |
* If set to NULL the first matching element is returned. |
22e77e44 |
* @param flags Allows case as well as suffix-insensitive comparisons.
* @return Found tag or NULL, changing key or value leads to undefined behavior. |
a6d18a0e |
*/ |
d9f80ea2 |
attribute_deprecated AVDictionaryEntry *
av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); |
a6d18a0e |
|
a181981e |
/** |
32e6f246 |
* Set the given tag in *pm, overwriting an existing tag. |
26cc5310 |
* |
983ec304 |
* @param pm pointer to a pointer to a metadata struct. If *pm is NULL
* a metadata struct is allocated and put in *pm. |
32e6f246 |
* @param key tag key to add to *pm (will be av_strduped depending on flags)
* @param value tag value to add to *pm (will be av_strduped depending on flags). |
160c896c |
* Passing a NULL value will cause an existing tag to be deleted. |
a181981e |
* @return >= 0 on success otherwise an error code <0
*/ |
d9f80ea2 |
attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags); |
a6d18a0e |
|
094d9df7 |
/** |
03700d39 |
* This function is provided for compatibility reason and currently does nothing. |
f610a9f2 |
*/ |
03700d39 |
attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
const AVMetadataConv *s_conv); |
f610a9f2 |
/** |
d9f80ea2 |
* Copy metadata from one AVDictionary struct into another.
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, |
7f88a5bf |
* this function will allocate a struct for you and put it in *dst |
d9f80ea2 |
* @param src pointer to source AVDictionary struct |
7f88a5bf |
* @param flags flags to use when setting metadata in *dst |
d2d67e42 |
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag |
7f88a5bf |
*/ |
d9f80ea2 |
attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags); |
7f88a5bf |
/** |
d9f80ea2 |
* Free all the memory allocated for an AVDictionary struct. |
094d9df7 |
*/ |
d9f80ea2 |
attribute_deprecated void av_metadata_free(AVDictionary **m);
/**
* @}
*/
#endif |
094d9df7 |
|
a6d18a0e |
|
de6d9b64 |
/* packet functions */
|
3217cb42 |
/** |
49bd8e4b |
* Allocate and read the payload of a packet and initialize its |
d1b9adf2 |
* fields with default values. |
3217cb42 |
*
* @param pkt packet |
4f57fa8c |
* @param size desired payload size
* @return >0 (read size) if OK, AVERROR_xxx otherwise |
3217cb42 |
*/ |
471fe57e |
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); |
3217cb42 |
|
de6d9b64 |
|
6bfc2683 |
/** |
fa8cc126 |
* Read data and append it to the current content of the AVPacket.
* If pkt->size is 0 this is identical to av_get_packet. |
6bfc2683 |
* Note that this uses av_grow_packet and thus involves a realloc
* which is inefficient. Thus this function should only be used
* when there is no reasonable way to know (an upper bound of)
* the final size.
*
* @param pkt packet
* @param size amount of data to read
* @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
* will not be lost even if an error occurs.
*/ |
471fe57e |
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); |
6bfc2683 |
|
de6d9b64 |
/*************************************************/ |
916c80e9 |
/* fractional numbers for exact pts handling */
|
671adb17 |
/** |
4f57fa8c |
* The exact value of the fractional number is: 'val + num / den'.
* num is assumed to be 0 <= num < den. |
4c08b2bd |
*/ |
916c80e9 |
typedef struct AVFrac { |
115329f1 |
int64_t val, num, den; |
52e57500 |
} AVFrac; |
916c80e9 |
/*************************************************/ |
b9a281db |
/* input/output formats */ |
de6d9b64 |
|
7caf0cc6 |
struct AVCodecTag;
|
76c56376 |
/**
* This structure contains the data a format has to probe a file.
*/ |
b9a281db |
typedef struct AVProbeData { |
5c91a675 |
const char *filename; |
e5f58f81 |
unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
int buf_size; /**< Size of buf except extra allocated bytes */ |
b9a281db |
} AVProbeData;
|
22e77e44 |
#define AVPROBE_SCORE_MAX 100 ///< maximum score, half of that is used for file-extension-based detection |
87e87886 |
#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer |
de6d9b64 |
typedef struct AVFormatParameters { |
bffd4dd1 |
#if FF_API_FORMAT_PARAMETERS |
b2592ea4 |
attribute_deprecated AVRational time_base; |
bffd4dd1 |
attribute_deprecated int sample_rate;
attribute_deprecated int channels; |
89d1b7f4 |
attribute_deprecated int width;
attribute_deprecated int height; |
f91ccb1d |
attribute_deprecated enum PixelFormat pix_fmt; |
d20576d0 |
attribute_deprecated int channel; /**< Used to select DV channel. */ |
fc68a8f7 |
attribute_deprecated const char *standard; /**< deprecated, use demuxer-specific options instead. */ |
fb37d573 |
attribute_deprecated unsigned int mpeg2ts_raw:1; /**< deprecated, use mpegtsraw demuxer */ |
17a5556d |
/**< deprecated, use mpegtsraw demuxer-specific options instead */
attribute_deprecated unsigned int mpeg2ts_compute_pcr:1; |
4779f593 |
attribute_deprecated unsigned int initial_pause:1; /**< Do not begin to play the stream
immediately (RTSP only). */ |
603b8bc2 |
attribute_deprecated unsigned int prealloced_context:1; |
17a5556d |
#endif |
de6d9b64 |
} AVFormatParameters;
|
ebb92e07 |
//! Demuxer will use avio_open, no opened file should be provided by the caller. |
40d9c544 |
#define AVFMT_NOFILE 0x0001 |
4f57fa8c |
#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */
#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */
#define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for
raw picture data. */
#define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */
#define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */
#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */ |
58ec7e00 |
#define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */ |
25918212 |
#define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */ |
ab5a0175 |
#define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */ |
bb62d5c1 |
#define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */ |
69fa2396 |
#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */
#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ |
094aa84b |
#define AVFMT_TS_NONSTRICT 0x8000 /**< Format does not require strictly
increasing timestamps, but they must
still be monotonic */ |
b9a281db |
typedef struct AVOutputFormat { |
de6d9b64 |
const char *name; |
bde15e74 |
/**
* Descriptive name for the format, meant to be more human-readable |
819174fa |
* than name. You should use the NULL_IF_CONFIG_SMALL() macro |
bde15e74 |
* to define it.
*/ |
de6d9b64 |
const char *long_name;
const char *mime_type; |
4f57fa8c |
const char *extensions; /**< comma-separated filename extensions */ |
76c56376 |
/**
* size of private data so that it can be allocated in the wrapper
*/ |
b9a281db |
int priv_data_size; |
de6d9b64 |
/* output support */ |
43d414ba |
enum CodecID audio_codec; /**< default audio codec */
enum CodecID video_codec; /**< default video codec */ |
de6d9b64 |
int (*write_header)(struct AVFormatContext *); |
e928649b |
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); |
de6d9b64 |
int (*write_trailer)(struct AVFormatContext *); |
76c56376 |
/** |
a1c4b65b |
* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE,
* AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
* AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS |
76c56376 |
*/ |
b9a281db |
int flags; |
a2eef3e9 |
void *dummy;
|
78cb7273 |
int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
AVPacket *in, int flush); |
7caf0cc6 |
/** |
78cb7273 |
* List of supported codec_id-codec_tag pairs, ordered by "better |
22e77e44 |
* choice first". The arrays are all terminated by CODEC_ID_NONE. |
7caf0cc6 |
*/ |
c1854592 |
const struct AVCodecTag * const *codec_tag; |
7caf0cc6 |
|
11bf3847 |
enum CodecID subtitle_codec; /**< default subtitle codec */
|
451d566f |
#if FF_API_OLD_METADATA2 |
719e721a |
const AVMetadataConv *metadata_conv; |
03700d39 |
#endif |
f610a9f2 |
|
cf99e4aa |
const AVClass *priv_class; ///< AVClass for the private context
|
b9a281db |
/* private fields */
struct AVOutputFormat *next;
} AVOutputFormat; |
de6d9b64 |
|
b9a281db |
typedef struct AVInputFormat { |
76c56376 |
/**
* A comma separated list of short names for the format. New names |
ac3ccbc0 |
* may be appended with a minor bump.
*/ |
b9a281db |
const char *name; |
76c56376 |
|
bde15e74 |
/**
* Descriptive name for the format, meant to be more human-readable |
819174fa |
* than name. You should use the NULL_IF_CONFIG_SMALL() macro |
bde15e74 |
* to define it.
*/ |
b9a281db |
const char *long_name; |
76c56376 |
/**
* Size of private data so that it can be allocated in the wrapper.
*/ |
b9a281db |
int priv_data_size; |
76c56376 |
|
65d7d68b |
/** |
22e77e44 |
* Tell if a given file has a chance of being parsed as this format. |
5d81d641 |
* The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
* big so you do not have to check for that unless you need more. |
65d7d68b |
*/ |
b9a281db |
int (*read_probe)(AVProbeData *); |
76c56376 |
/**
* Read the format header and initialize the AVFormatContext
* structure. Return 0 if OK. 'ap' if non-NULL contains
* additional parameters. Only used in raw format right
* now. 'av_new_stream' should be called to create new streams.
*/ |
de6d9b64 |
int (*read_header)(struct AVFormatContext *,
AVFormatParameters *ap); |
76c56376 |
/**
* Read one packet and put it in 'pkt'. pts and flags are also
* set. 'av_new_stream' can be called only if the flag |
2899a28c |
* AVFMTCTX_NOHEADER is used and only in the calling thread (not in a
* background thread). |
76c56376 |
* @return 0 on success, < 0 on error.
* When returning an error, pkt must not have been allocated
* or must be freed before returning
*/ |
de6d9b64 |
int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); |
76c56376 |
/**
* Close the stream. The AVFormatContext and AVStreams are not
* freed by this function
*/ |
de6d9b64 |
int (*read_close)(struct AVFormatContext *); |
1de2db8f |
|
634e0304 |
#if FF_API_READ_SEEK |
115329f1 |
/** |
4f57fa8c |
* Seek to a given timestamp relative to the frames in
* stream component stream_index. |
22e77e44 |
* @param stream_index Must not be -1.
* @param flags Selects which direction should be preferred if no exact
* match is available. |
05ce0f11 |
* @return >= 0 on success (but not necessarily the new offset) |
3ba1438d |
*/ |
a15c7fd6 |
attribute_deprecated int (*read_seek)(struct AVFormatContext *,
int stream_index, int64_t timestamp, int flags); |
1de2db8f |
#endif |
8d14a25c |
/** |
4f57fa8c |
* Gets the next timestamp in stream[stream_index].time_base units. |
d9526386 |
* @return the timestamp or AV_NOPTS_VALUE if an error occurred |
8d14a25c |
*/
int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit); |
76c56376 |
/**
* Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER.
*/ |
de6d9b64 |
int flags; |
76c56376 |
/**
* If extensions are defined, then no probe is done. You should
* usually not use extension format guessing because it is not
* reliable enough
*/ |
b9a281db |
const char *extensions; |
76c56376 |
/**
* General purpose read-only value that the format can use.
*/ |
b9a281db |
int value; |
fb2758c8 |
|
76c56376 |
/**
* Start/resume playing - only meaningful if using a network-based format
* (RTSP).
*/ |
fb2758c8 |
int (*read_play)(struct AVFormatContext *);
|
76c56376 |
/**
* Pause playing - only meaningful if using a network-based format
* (RTSP).
*/ |
fb2758c8 |
int (*read_pause)(struct AVFormatContext *);
|
c1854592 |
const struct AVCodecTag * const *codec_tag; |
7caf0cc6 |
|
1de2db8f |
/** |
49bd8e4b |
* Seek to timestamp ts. |
1de2db8f |
* Seeking will be done so that the point from which all active streams
* can be presented successfully will be closest to ts and within min/max_ts.
* Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
*/ |
882fb0a3 |
int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); |
1de2db8f |
|
451d566f |
#if FF_API_OLD_METADATA2 |
719e721a |
const AVMetadataConv *metadata_conv; |
03700d39 |
#endif |
f610a9f2 |
|
49202620 |
const AVClass *priv_class; ///< AVClass for the private context
|
b9a281db |
/* private fields */
struct AVInputFormat *next;
} AVInputFormat; |
de6d9b64 |
|
57004ff1 |
enum AVStreamParseType {
AVSTREAM_PARSE_NONE,
AVSTREAM_PARSE_FULL, /**< full parsing and repack */ |
4f57fa8c |
AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */ |
78cb7273 |
AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */ |
74a6df59 |
AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */ |
57004ff1 |
};
|
fb2758c8 |
typedef struct AVIndexEntry {
int64_t pos;
int64_t timestamp;
#define AVINDEX_KEYFRAME 0x0001 |
30a43f2d |
int flags:2; |
4f57fa8c |
int 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).
int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ |
fb2758c8 |
} AVIndexEntry;
|
90c2295b |
#define AV_DISPOSITION_DEFAULT 0x0001
#define AV_DISPOSITION_DUB 0x0002
#define AV_DISPOSITION_ORIGINAL 0x0004
#define AV_DISPOSITION_COMMENT 0x0008
#define AV_DISPOSITION_LYRICS 0x0010
#define AV_DISPOSITION_KARAOKE 0x0020 |
76c56376 |
/**
* Track should be used during playback by default.
* Useful for subtitle track that should be displayed
* even when user did not explicitly ask for subtitles.
*/ |
7a617a86 |
#define AV_DISPOSITION_FORCED 0x0040 |
8270db38 |
#define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */
#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ |
2ea7e1f0 |
#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ |
90c2295b |
|
ba66ae94 |
/**
* Stream structure.
* New fields can be added to the end with minor version bumps. |
8bfb108b |
* Removal, reordering and changes to existing fields require a major |
ba66ae94 |
* version bump. |
8bfb108b |
* sizeof(AVStream) must not be used outside libav*. |
ba66ae94 |
*/ |
de6d9b64 |
typedef struct AVStream { |
43d414ba |
int index; /**< stream index in AVFormatContext */ |
4f57fa8c |
int id; /**< format-specific stream ID */ |
43d414ba |
AVCodecContext *codec; /**< codec context */ |
b4b87d48 |
/** |
22e77e44 |
* Real base framerate of the stream.
* This is the lowest framerate with which all timestamps can be |
864ff8c1 |
* represented accurately (it is the least common multiple of all |
22e77e44 |
* framerates in the stream). Note, this value is just a guess!
* For example, if the time base is 1/90000 and all frames have either |
4f57fa8c |
* approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. |
b4b87d48 |
*/
AVRational r_frame_rate; |
de6d9b64 |
void *priv_data; |
82583548 |
|
b9a281db |
/* internal data used in av_find_stream_info() */ |
82583548 |
int64_t first_dts; |
76c56376 |
/**
* encoding: pts generation when outputting stream
*/ |
a9fd2b19 |
struct AVFrac pts; |
5b28c8c3 |
/** |
8bfb108b |
* This is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. For fixed-fps content, |
22e77e44 |
* time base should be 1/framerate and timestamp increments should be 1. |
12763671 |
* decoding: set by libavformat
* encoding: set by libavformat in av_write_header |
5b28c8c3 |
*/ |
9ee91c2f |
AVRational time_base; |
43d414ba |
int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ |
a48b7a6b |
/* ffmpeg.c private use */ |
4f57fa8c |
int stream_copy; /**< If set, just copy stream. */
enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. |
76c56376 |
|
b4aea108 |
//FIXME move stuff to a flags field? |
76c56376 |
/**
* Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
* MN: dunno if that is the right place for it
*/ |
115329f1 |
float quality; |
76c56376 |
|
6d96a9b9 |
/** |
8bfb108b |
* Decoding: pts of the first frame of the stream, in stream time base.
* Only set this if you are absolutely 100% sure that the value you set
* it to really is the pts of the first frame. |
4854c253 |
* This may be undefined (AV_NOPTS_VALUE). |
133055c5 |
* @note The ASF header does NOT contain a correct start_time the ASF
* demuxer must NOT set this. |
6d96a9b9 |
*/ |
115329f1 |
int64_t start_time; |
76c56376 |
|
e26381b6 |
/** |
8bfb108b |
* Decoding: duration of the stream, in stream time base. |
e26381b6 |
* If a source file does not specify a duration, but does specify |
4f57fa8c |
* a bitrate, this value will be estimated from bitrate and file size. |
e26381b6 |
*/ |
ee404803 |
int64_t duration; |
fb2758c8 |
/* av_read_frame() support */ |
57004ff1 |
enum AVStreamParseType need_parsing; |
fb2758c8 |
struct AVCodecParserContext *parser; |
6ec87caa |
|
fb2758c8 |
int64_t cur_dts; |
635fbcb1 |
int last_IP_duration;
int64_t last_IP_pts; |
fb2758c8 |
/* av_seek_frame() support */ |
4f57fa8c |
AVIndexEntry *index_entries; /**< Only used if the format does not
support seeking natively. */ |
fb2758c8 |
int nb_index_entries; |
191e8ca7 |
unsigned int index_entries_allocated_size; |
115329f1 |
|
b4b87d48 |
int64_t nb_frames; ///< number of frames in this stream if known or 0 |
504ee036 |
|
4f57fa8c |
int disposition; /**< AV_DISPOSITION_* bit field */ |
0bef08e5 |
AVProbeData probe_data; |
0d84a8f6 |
#define MAX_REORDER_DELAY 16
int64_t pts_buffer[MAX_REORDER_DELAY+1]; |
c30a4489 |
/**
* sample aspect ratio (0 if unknown)
* - encoding: Set by user.
* - decoding: Set by libavformat.
*/
AVRational sample_aspect_ratio; |
f526adaf |
|
d2d67e42 |
AVDictionary *metadata; |
3a41c2f7 |
|
31769dad |
/* Intended mostly for av_read_frame() support. Not supposed to be used by */
/* external applications; try to use something else if at all possible. */ |
3a41c2f7 |
const uint8_t *cur_ptr;
int cur_len;
AVPacket cur_pkt; |
27ca0a79 |
// Timestamp generation support:
/**
* Timestamp corresponding to the last dts sync point.
*
* Initialized when AVCodecParserContext.dts_sync_point >= 0 and
* a DTS is received from the underlying container. Otherwise set to
* AV_NOPTS_VALUE by default.
*/
int64_t reference_dts; |
86cb7e33 |
/**
* Number of packets to buffer for codec probing
* NOT PART OF PUBLIC API
*/ |
48616887 |
#define MAX_PROBE_PACKETS 2500 |
86cb7e33 |
int probe_packets; |
ddce56ef |
/** |
e07b882b |
* last packet in packet_buffer for this stream when muxing. |
ddce56ef |
* used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav*
*/ |
e07b882b |
struct AVPacketList *last_in_packet_buffer; |
02b398ef |
/**
* Average framerate
*/
AVRational avg_frame_rate; |
6c6e6ef5 |
/**
* Number of frames that have been demuxed during av_find_stream_info()
*/
int codec_info_nb_frames; |
fd0368e7 |
/** |
fa12fb3b |
* Stream Identifier
* This is the MPEG-TS stream identifier +1
* 0 means unknown
*/
int stream_identifier;
/** |
fd0368e7 |
* Stream informations used internally by av_find_stream_info()
*/
#define MAX_STD_TIMEBASES (60*12+5)
struct {
int64_t last_dts;
int64_t duration_gcd;
int duration_count;
double duration_error[MAX_STD_TIMEBASES];
int64_t codec_info_duration;
} *info; |
5b56ad03 |
/**
* flag to indicate that probing is requested
* NOT PART OF PUBLIC API
*/
int request_probe; |
de6d9b64 |
} AVStream;
|
15afa396 |
#define AV_PROGRAM_RUNNING 1
|
ba66ae94 |
/**
* New fields can be added to the end with minor version bumps. |
8bfb108b |
* Removal, reordering and changes to existing fields require a major |
ba66ae94 |
* version bump. |
8bfb108b |
* sizeof(AVProgram) must not be used outside libav*. |
ba66ae94 |
*/ |
15afa396 |
typedef struct AVProgram {
int id;
int flags;
enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller |
526efa10 |
unsigned int *stream_index;
unsigned int nb_stream_indexes; |
d2d67e42 |
AVDictionary *metadata; |
24adef14 |
int program_num;
int pmt_pid; |
5501afa6 |
int pcr_pid; |
15afa396 |
} AVProgram;
|
43d414ba |
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present |
da24c5e3 |
(streams are added dynamically) */
|
79d7836a |
typedef struct AVChapter { |
4f57fa8c |
int id; ///< unique ID to identify the chapter
AVRational time_base; ///< time base in which the start/end timestamps are specified |
8931e7b4 |
int64_t start, end; ///< chapter start/end time in time_base units |
d2d67e42 |
AVDictionary *metadata; |
79d7836a |
} AVChapter;
|
252f17e2 |
/** |
4f57fa8c |
* Format I/O context. |
252f17e2 |
* New fields can be added to the end with minor version bumps. |
8bfb108b |
* Removal, reordering and changes to existing fields require a major |
252f17e2 |
* version bump. |
8bfb108b |
* sizeof(AVFormatContext) must not be used outside libav*. |
252f17e2 |
*/ |
de6d9b64 |
typedef struct AVFormatContext { |
1447aac4 |
const AVClass *av_class; /**< Set by avformat_alloc_context. */ |
4f57fa8c |
/* Can only be iformat or oformat, not both at the same time. */ |
b9a281db |
struct AVInputFormat *iformat;
struct AVOutputFormat *oformat; |
de6d9b64 |
void *priv_data; |
471fe57e |
AVIOContext *pb; |
db69c2e5 |
unsigned int nb_streams; |
38aab35f |
AVStream **streams; |
43d414ba |
char filename[1024]; /**< input or output filename */ |
de6d9b64 |
/* stream info */ |
4568325a |
int64_t timestamp; |
6a58e151 |
|
4f57fa8c |
int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
/* private data for pts handling (do not modify directly). */ |
76c56376 |
/**
* This buffer is only needed when packets were already buffered but
* not decoded, for example to get the codec parameters in MPEG
* streams.
*/ |
ee404803 |
struct AVPacketList *packet_buffer;
|
76c56376 |
/**
* Decoding: position of the first frame of the component, in
* AV_TIME_BASE fractional seconds. NEVER set this value directly:
* It is deduced from the AVStream values.
*/ |
115329f1 |
int64_t start_time; |
76c56376 |
/**
* Decoding: duration of the stream, in AV_TIME_BASE fractional
* seconds. Only set this value if you know none of the individual stream
* durations and also dont set any of them. This is deduced from the
* AVStream values if not set.
*/ |
ee404803 |
int64_t duration; |
76c56376 |
/**
* decoding: total file size, 0 if unknown
*/ |
ee404803 |
int64_t file_size; |
76c56376 |
/**
* Decoding: total stream bitrate in bit/s, 0 if not
* available. Never set it directly if the file_size and the |
2d2b5a14 |
* duration are known as FFmpeg can compute it automatically. |
76c56376 |
*/ |
ee404803 |
int bit_rate; |
fb2758c8 |
/* av_read_frame() support */
AVStream *cur_st;
/* av_seek_frame() support */ |
ec906fcd |
int64_t data_offset; /**< offset of the first packet */ |
115329f1 |
|
2db3c638 |
int mux_rate; |
92400be2 |
unsigned int packet_size; |
17c88cb0 |
int preload;
int max_delay; |
8108551a |
|
115329f1 |
#define AVFMT_NOOUTPUTLOOP -1
#define AVFMT_INFINITEOUTPUTLOOP 0 |
76c56376 |
/**
* number of times to loop output in formats that support it
*/ |
8108551a |
int loop_output; |
115329f1 |
|
30bc6613 |
int flags; |
22e77e44 |
#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. |
4f57fa8c |
#define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. |
c55806e3 |
#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS |
fe8344a2 |
#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled |
28734ac9 |
#if FF_API_FLAG_RTP_HINT
#define AVFMT_FLAG_RTP_HINT 0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead
#endif |
05e84c95 |
#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. |
2905e3ff |
#define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload |
8a68697d |
#define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) |
49202620 |
#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) |
5c08c7b2 |
#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Dont merge side data but keep it seperate. |
5894e1bb |
int loop_input; |
76c56376 |
/**
* decoding: size of data to probe; encoding: unused.
*/ |
9e6c9470 |
unsigned int probesize; |
a44b3c4d |
/** |
4f57fa8c |
* Maximum time (in AV_TIME_BASE units) during which the input should
* be analyzed in av_find_stream_info(). |
a44b3c4d |
*/
int max_analyze_duration; |
c964c2c7 |
const uint8_t *key;
int keylen; |
15afa396 |
unsigned int nb_programs;
AVProgram **programs; |
62600469 |
/**
* Forced video codec_id. |
4f57fa8c |
* Demuxing: Set by user. |
62600469 |
*/
enum CodecID video_codec_id; |
76c56376 |
|
62600469 |
/**
* Forced audio codec_id. |
4f57fa8c |
* Demuxing: Set by user. |
62600469 |
*/
enum CodecID audio_codec_id; |
76c56376 |
|
62600469 |
/**
* Forced subtitle codec_id. |
4f57fa8c |
* Demuxing: Set by user. |
62600469 |
*/
enum CodecID subtitle_codec_id; |
3dea63bd |
/** |
22e77e44 |
* Maximum amount of memory in bytes to use for the index of each stream.
* If the index exceeds this size, entries will be discarded as |
3dea63bd |
* needed to maintain a smaller size. This can lead to slower or less
* accurate seeking (depends on demuxer). |
4f57fa8c |
* Demuxers for which a full in-memory index is mandatory will ignore |
3dea63bd |
* this.
* muxing : unused
* demuxing: set by user
*/
unsigned int max_index_size; |
ab8ab30c |
/** |
ffa71b2b |
* Maximum amount of memory in bytes to use for buffering frames |
4f57fa8c |
* obtained from realtime capture devices. |
ab8ab30c |
*/
unsigned int max_picture_buffer; |
79d7836a |
|
fbabf1e9 |
unsigned int nb_chapters; |
79d7836a |
AVChapter **chapters; |
45b2b05f |
/** |
4f57fa8c |
* Flags to enable debugging. |
45b2b05f |
*/
int debug;
#define FF_FDEBUG_TS 0x0001 |
0bef08e5 |
/** |
4f57fa8c |
* Raw packets from the demuxer, prior to parsing and decoding. |
0bef08e5 |
* This buffer is used for buffering packets until the codec can
* be identified, as parsing cannot be done without knowing the
* codec.
*/
struct AVPacketList *raw_packet_buffer; |
5c5b1731 |
struct AVPacketList *raw_packet_buffer_end;
struct AVPacketList *packet_buffer_end; |
47146dfb |
|
d2d67e42 |
AVDictionary *metadata; |
af122d6a |
/**
* Remaining size available for raw_packet_buffer, in bytes.
* NOT PART OF PUBLIC API
*/ |
48616887 |
#define RAW_PACKET_BUFFER_SIZE 2500000 |
af122d6a |
int raw_packet_buffer_remaining_size; |
b8819c85 |
/**
* Start time of the stream in real world time, in microseconds
* since the unix epoch (00:00 1st January 1970). That is, pts=0
* in the stream was captured at this real world time.
* - encoding: Set by user.
* - decoding: Unused.
*/
int64_t start_time_realtime; |
30315a8d |
/**
* decoding: number of frames used to probe fps
*/
int fps_probe_size; |
24adef14 |
/**
* Transport stream id.
* This will be moved into demuxer private options. Thus no API/ABI compatibility
*/
int ts_id; |
de6d9b64 |
} AVFormatContext;
typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;
|
aeedac95 |
/**
* If f is NULL, returns the first registered input format, |
22e77e44 |
* if f is non-NULL, returns the next registered input format after f |
aeedac95 |
* or NULL if f is the last one.
*/ |
84be6e72 |
AVInputFormat *av_iformat_next(AVInputFormat *f); |
aeedac95 |
/**
* If f is NULL, returns the first registered output format, |
22e77e44 |
* if f is non-NULL, returns the next registered output format after f |
aeedac95 |
* or NULL if f is the last one.
*/ |
84be6e72 |
AVOutputFormat *av_oformat_next(AVOutputFormat *f); |
de6d9b64 |
|
a9bf9d8e |
#if FF_API_GUESS_IMG2_CODEC
attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename);
#endif |
290c5fa6 |
|
22e77e44 |
/* XXX: Use automatic init with either ELF sections or C file parser */
/* modules. */ |
de6d9b64 |
|
b9a281db |
/* utils.c */
void av_register_input_format(AVInputFormat *format);
void av_register_output_format(AVOutputFormat *format); |
f48b0fa2 |
/** |
49bd8e4b |
* Return the output format in the list of registered output formats
* which best matches the provided parameters, or return NULL if |
f48b0fa2 |
* there is no match.
*
* @param short_name if non-NULL checks if short_name matches with the
* names of the registered formats
* @param filename if non-NULL checks if filename terminates with the
* extensions of the registered formats
* @param mime_type if non-NULL checks if mime_type matches with the
* MIME type of the registered formats
*/ |
a1f547b9 |
AVOutputFormat *av_guess_format(const char *short_name, |
94b1f338 |
const char *filename,
const char *mime_type); |
3217cb42 |
/** |
49bd8e4b |
* Guess the codec ID based upon muxer and filename. |
3217cb42 |
*/ |
115329f1 |
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, |
78cb7273 |
const char *filename, const char *mime_type, |
72415b2a |
enum AVMediaType type); |
de6d9b64 |
|
3217cb42 |
/** |
49bd8e4b |
* Send a nice hexadecimal dump of a buffer to the specified file stream. |
750f0e1f |
*
* @param f The file stream pointer where the dump should be sent to. |
3217cb42 |
* @param buf buffer
* @param size buffer size |
750f0e1f |
* |
08ad81cb |
* @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2 |
3217cb42 |
*/ |
fb2758c8 |
void av_hex_dump(FILE *f, uint8_t *buf, int size); |
3217cb42 |
/** |
49bd8e4b |
* Send a nice hexadecimal dump of a buffer to the log. |
750f0e1f |
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct.
* @param level The importance level of the message, lower values signifying
* higher importance.
* @param buf buffer
* @param size buffer size
* |
08ad81cb |
* @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2 |
750f0e1f |
*/
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
/** |
49bd8e4b |
* Send a nice dump of a packet to the specified file stream. |
750f0e1f |
*
* @param f The file stream pointer where the dump should be sent to. |
3217cb42 |
* @param pkt packet to dump |
4f57fa8c |
* @param dump_payload True if the payload must be displayed, too. |
08ad81cb |
* @param st AVStream that the packet belongs to |
3217cb42 |
*/ |
08ad81cb |
void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
|
de6d9b64 |
|
750f0e1f |
/** |
49bd8e4b |
* Send a nice dump of a packet to the log. |
750f0e1f |
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct.
* @param level The importance level of the message, lower values signifying
* higher importance.
* @param pkt packet to dump |
4f57fa8c |
* @param dump_payload True if the payload must be displayed, too. |
08ad81cb |
* @param st AVStream that the packet belongs to |
750f0e1f |
*/ |
08ad81cb |
void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
AVStream *st);
|
c5704b2b |
#if FF_API_PKT_DUMP
attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); |
08ad81cb |
attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
int dump_payload); |
17ca374c |
#endif |
750f0e1f |
|
4815e246 |
/** |
49bd8e4b |
* Initialize libavformat and register all the muxers, demuxers and |
4815e246 |
* protocols. If you do not call this function, then you can select
* exactly which formats you want to support.
*
* @see av_register_input_format()
* @see av_register_output_format() |
5d377501 |
* @see av_register_protocol() |
4815e246 |
*/ |
94988531 |
void av_register_all(void); |
de6d9b64 |
|
7693b93e |
/** |
49bd8e4b |
* Get the CodecID for the given codec tag tag. |
7693b93e |
* If no codec id is found returns CODEC_ID_NONE.
*
* @param tags list of supported codec_id-codec_tag pairs, as stored
* in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
*/ |
15545a09 |
enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); |
7693b93e |
/** |
49bd8e4b |
* Get the codec tag for the given codec id id. |
7693b93e |
* If no codec tag is found returns 0.
*
* @param tags list of supported codec_id-codec_tag pairs, as stored
* in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
*/ |
15545a09 |
unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id); |
7caf0cc6 |
|
b9a281db |
/* media file input */ |
3217cb42 |
/** |
49bd8e4b |
* Find AVInputFormat based on the short name of the input format. |
3217cb42 |
*/ |
b9a281db |
AVInputFormat *av_find_input_format(const char *short_name); |
3217cb42 |
/** |
49bd8e4b |
* Guess the file format. |
3217cb42 |
* |
4f57fa8c |
* @param is_opened Whether the file is already opened; determines whether
* demuxers with or without AVFMT_NOFILE are probed. |
3217cb42 |
*/ |
94988531 |
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); |
3217cb42 |
/** |
49bd8e4b |
* Guess the file format. |
8e2ee182 |
*
* @param is_opened Whether the file is already opened; determines whether
* demuxers with or without AVFMT_NOFILE are probed. |
c99d506b |
* @param score_max A probe score larger that this is required to accept a
* detection, the variable is set to the actual detection
* score afterwards.
* If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended |
8e2ee182 |
* to retry with a larger probe buffer.
*/
AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
/** |
5b56ad03 |
* Guess the file format.
*
* @param is_opened Whether the file is already opened; determines whether
* demuxers with or without AVFMT_NOFILE are probed.
* @param score_ret The score of the best detection.
*/
AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret);
/** |
070e5ba5 |
* Probe a bytestream to determine the input format. Each time a probe returns
* with a score that is too low, the probe buffer size is increased and another
* attempt is made. When the maximum probe size is reached, the input format
* with the highest score is returned.
*
* @param pb the bytestream to probe
* @param fmt the input format is put here
* @param filename the filename of the stream
* @param logctx the log context
* @param offset the offset within the bytestream to probe from
* @param max_probe_size the maximum probe buffer size (zero for default)
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*/ |
471fe57e |
int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, |
070e5ba5 |
const char *filename, void *logctx,
unsigned int offset, unsigned int max_probe_size);
|
603b8bc2 |
#if FF_API_FORMAT_PARAMETERS |
070e5ba5 |
/** |
49bd8e4b |
* Allocate all the structures needed to read an input stream. |
3217cb42 |
* This does not open the needed codecs for decoding the stream[s]. |
603b8bc2 |
* @deprecated use avformat_open_input instead. |
3217cb42 |
*/ |
603b8bc2 |
attribute_deprecated int av_open_input_stream(AVFormatContext **ic_ptr, |
471fe57e |
AVIOContext *pb, const char *filename, |
da24c5e3 |
AVInputFormat *fmt, AVFormatParameters *ap); |
3217cb42 |
/** |
49bd8e4b |
* Open a media file as input. The codecs are not opened. Only the file |
3217cb42 |
* header (if present) is read.
* |
4f57fa8c |
* @param ic_ptr The opened media file handle is put here.
* @param filename filename to open
* @param fmt If non-NULL, force the file format to use. |
3217cb42 |
* @param buf_size optional buffer size (zero if default is OK) |
78cb7273 |
* @param ap Additional parameters needed when opening the file
* (NULL if default). |
4f57fa8c |
* @return 0 if OK, AVERROR_xxx otherwise |
603b8bc2 |
*
* @deprecated use avformat_open_input instead. |
3217cb42 |
*/ |
603b8bc2 |
attribute_deprecated int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, |
b9a281db |
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap); |
603b8bc2 |
#endif |
88a28965 |
|
88808c60 |
/** |
05e84c95 |
* Open an input stream and read the header. The codecs are not opened.
* The stream must be closed with av_close_input_file().
*
* @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
* May be a pointer to NULL, in which case an AVFormatContext is allocated by this
* function and written into ps.
* Note that a user-supplied AVFormatContext will be freed on failure.
* @param filename Name of the stream to open.
* @param fmt If non-NULL, this parameter forces a specific input format.
* Otherwise the format is autodetected.
* @param options A dictionary filled with AVFormatContext and demuxer-private options.
* On return this parameter will be destroyed and replaced with a dict containing
* options that were not found. May be NULL.
*
* @return 0 on success, a negative AVERROR on failure.
*
* @note If you want to use custom IO, preallocate the format context and set its pb field.
*/
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); |
88a28965 |
|
49202620 |
int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap);
|
88808c60 |
/** |
49bd8e4b |
* Allocate an AVFormatContext. |
4ed68fdf |
* avformat_free_context() can be used to free the context and everything
* allocated by the framework within it. |
88808c60 |
*/ |
88a28965 |
AVFormatContext *avformat_alloc_context(void); |
b9a281db |
|
5ecdfd00 |
#if FF_API_ALLOC_OUTPUT_CONTEXT |
3217cb42 |
/** |
5ecdfd00 |
* @deprecated deprecated in favor of avformat_alloc_output_context2()
*/
attribute_deprecated
AVFormatContext *avformat_alloc_output_context(const char *format,
AVOutputFormat *oformat,
const char *filename);
#endif
/**
* Allocate an AVFormatContext for an output format.
* avformat_free_context() can be used to free the context and
* everything allocated by the framework within it.
*
* @param *ctx is set to the created format context, or to NULL in
* case of failure
* @param oformat format to use for allocating the context, if NULL
* format_name and filename are used instead
* @param format_name the name of output format to use for allocating the
* context, if NULL filename is used instead
* @param filename the name of the filename to use for allocating the
* context, may be NULL
* @return >= 0 in case of success, a negative AVERROR code in case of
* failure |
7d727f13 |
*/ |
5ecdfd00 |
int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat,
const char *format_name, const char *filename); |
7d727f13 |
/** |
49bd8e4b |
* Read packets of a media file to get stream information. This |
3217cb42 |
* is useful for file formats with no headers such as MPEG. This |
22e77e44 |
* function also computes the real framerate in case of MPEG-2 repeat |
3217cb42 |
* frame mode.
* The logical file position is not changed by this function;
* examined packets may be buffered for later processing.
*
* @param ic media file handle |
4f57fa8c |
* @return >=0 if OK, AVERROR_xxx on error
* @todo Let the user decide somehow what information is needed so that
* we do not waste time getting stuff the user does not need. |
3217cb42 |
*/ |
b9a281db |
int av_find_stream_info(AVFormatContext *ic); |
3217cb42 |
/** |
9128ae08 |
* Find the "best" stream in the file.
* The best stream is determined according to various heuristics as the most
* likely to be what the user expects.
* If the decoder parameter is non-NULL, av_find_best_stream will find the
* default decoder for the stream's codec; streams for which no decoder can
* be found are ignored.
*
* @param ic media file handle
* @param type stream type: video, audio, subtitles, etc.
* @param wanted_stream_nb user-requested stream number,
* or -1 for automatic selection
* @param related_stream try to find a stream related (eg. in the same
* program) to this one, or -1 if none
* @param decoder_ret if non-NULL, returns the decoder for the
* selected stream
* @param flags flags; none are currently defined
* @return the non-negative stream number in case of success,
* AVERROR_STREAM_NOT_FOUND if no stream with the requested type
* could be found,
* AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
* @note If av_find_best_stream returns successfully and decoder_ret is not
* NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
*/
int av_find_best_stream(AVFormatContext *ic,
enum AVMediaType type,
int wanted_stream_nb,
int related_stream,
AVCodec **decoder_ret,
int flags);
/** |
49bd8e4b |
* Read a transport packet from a media file. |
3217cb42 |
* |
864ff8c1 |
* This function is obsolete and should never be used. |
3217cb42 |
* Use av_read_frame() instead.
*
* @param s media file handle
* @param pkt is filled |
4f57fa8c |
* @return 0 if OK, AVERROR_xxx on error |
3217cb42 |
*/ |
de6d9b64 |
int av_read_packet(AVFormatContext *s, AVPacket *pkt); |
3217cb42 |
/** |
49bd8e4b |
* Return the next frame of a stream. |
4faf628f |
* This function returns what is stored in the file, and does not validate
* that what is there are valid frames for the decoder. It will split what is
* stored in the file into frames and return one for each call. It will not
* omit invalid data between valid frames so as to give the decoder the maximum
* information possible for decoding. |
3217cb42 |
*
* The returned packet is valid
* until the next av_read_frame() or until av_close_input_file() and
* must be freed with av_free_packet. For video, the packet contains
* exactly one frame. For audio, it contains an integer number of
* frames if each frame has a known fixed size (e.g. PCM or ADPCM
* data). If the audio frames have a variable size (e.g. MPEG audio),
* then it contains one frame.
*
* pkt->pts, pkt->dts and pkt->duration are always set to correct |
22e77e44 |
* values in AVStream.time_base units (and guessed if the format cannot |
4f57fa8c |
* provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
* has B-frames, so it is better to rely on pkt->dts if you do not |
3217cb42 |
* decompress the payload.
* |
4f57fa8c |
* @return 0 if OK, < 0 on error or end of file |
3217cb42 |
*/ |
fb2758c8 |
int av_read_frame(AVFormatContext *s, AVPacket *pkt); |
3217cb42 |
/** |
49bd8e4b |
* Seek to the keyframe at timestamp. |
3217cb42 |
* 'timestamp' in 'stream_index'.
* @param stream_index If stream_index is (-1), a default
* stream is selected, and timestamp is automatically converted
* from AV_TIME_BASE units to the stream specific time_base. |
4f57fa8c |
* @param timestamp Timestamp in AVStream.time_base units
* or, if no stream is specified, in AV_TIME_BASE units. |
3217cb42 |
* @param flags flags which select direction and seeking mode
* @return >= 0 on success
*/ |
78cb7273 |
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
int flags); |
3217cb42 |
/** |
49bd8e4b |
* Seek to timestamp ts. |
d04768fa |
* Seeking will be done so that the point from which all active streams
* can be presented successfully will be closest to ts and within min/max_ts.
* Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
* |
22e77e44 |
* If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and |
d04768fa |
* are the file position (this may not be supported by all demuxers). |
22e77e44 |
* If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames |
d04768fa |
* in the stream with stream_index (this may not be supported by all demuxers). |
22e77e44 |
* Otherwise all timestamps are in units of the stream selected by stream_index
* or if stream_index is -1, in AV_TIME_BASE units.
* If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as |
d04768fa |
* keyframes (this may not be supported by all demuxers).
* |
22e77e44 |
* @param stream_index index of the stream which is used as time base reference |
d04768fa |
* @param min_ts smallest acceptable timestamp
* @param ts target timestamp
* @param max_ts largest acceptable timestamp
* @param flags flags |
32e543f8 |
* @return >=0 on success, error code otherwise |
998b6f7c |
* |
8a4d7a30 |
* @note This is part of the new seek API which is still under construction. |
22e77e44 |
* Thus do not use this yet. It may change at any time, do not expect
* ABI compatibility yet! |
d04768fa |
*/
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
/** |
49bd8e4b |
* Start playing a network-based stream (e.g. RTSP stream) at the |
4f57fa8c |
* current position. |
3217cb42 |
*/ |
fb2758c8 |
int av_read_play(AVFormatContext *s); |
3217cb42 |
/** |
49bd8e4b |
* Pause a network-based stream (e.g. RTSP stream). |
3217cb42 |
*
* Use av_read_play() to resume it.
*/ |
fb2758c8 |
int av_read_pause(AVFormatContext *s); |
3217cb42 |
/** |
49bd8e4b |
* Free a AVFormatContext allocated by av_open_input_stream. |
2506fd54 |
* @param s context to free
*/
void av_close_input_stream(AVFormatContext *s);
/** |
49bd8e4b |
* Close a media file (but not its codecs). |
3217cb42 |
*
* @param s media file handle
*/ |
de6d9b64 |
void av_close_input_file(AVFormatContext *s); |
3217cb42 |
/** |
4ed68fdf |
* Free an AVFormatContext and all its streams.
* @param s context to free
*/
void avformat_free_context(AVFormatContext *s);
/** |
49bd8e4b |
* Add a new stream to a media file. |
3217cb42 |
*
* Can only be called in the read_header() function. If the flag
* AVFMTCTX_NOHEADER is in the format context, then new streams
* can be added in read_packet too.
*
* @param s media file handle |
4f57fa8c |
* @param id file-format-dependent stream ID |
3217cb42 |
*/ |
b9a281db |
AVStream *av_new_stream(AVFormatContext *s, int id); |
15afa396 |
AVProgram *av_new_program(AVFormatContext *s, int id); |
3217cb42 |
/** |
2f35beae |
* Set the pts for a given stream. If the new values would be invalid
* (<= 0), it leaves the AVStream unchanged. |
3217cb42 |
*
* @param s stream
* @param pts_wrap_bits number of bits effectively used by the pts
* (used for wrap control, 33 is the value for MPEG)
* @param pts_num numerator to convert to seconds (MPEG: 1)
* @param pts_den denominator to convert to seconds (MPEG: 90000)
*/ |
9ee91c2f |
void av_set_pts_info(AVStream *s, int pts_wrap_bits, |
dec14949 |
unsigned int pts_num, unsigned int pts_den); |
de6d9b64 |
|
3ba1438d |
#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes |
4f57fa8c |
#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes |
2bf74f49 |
#define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number |
3ba1438d |
|
b754978a |
int av_find_default_stream_index(AVFormatContext *s); |
3217cb42 |
/** |
49bd8e4b |
* Get the index for a specific timestamp. |
4f57fa8c |
* @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
* to the timestamp which is <= the requested one, if backward
* is 0, then it will be >= |
3217cb42 |
* if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
* @return < 0 if no such timestamp could be found
*/ |
dc56fc38 |
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); |
3217cb42 |
/** |
49bd8e4b |
* Add an index entry into a sorted list. Update the entry if the list |
4f57fa8c |
* already contains it. |
3217cb42 |
* |
4f57fa8c |
* @param timestamp timestamp in the time base of the given stream |
3217cb42 |
*/ |
78cb7273 |
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
int size, int distance, int flags); |
3217cb42 |
/** |
49bd8e4b |
* Perform a binary search using av_index_search_timestamp() and |
3673f4ab |
* AVInputFormat.read_timestamp(). |
78cb7273 |
* This is not supposed to be called directly by a user application,
* but by demuxers. |
3217cb42 |
* @param target_ts target timestamp in the time base of the given stream
* @param stream_index stream number
*/ |
78cb7273 |
int av_seek_frame_binary(AVFormatContext *s, int stream_index,
int64_t target_ts, int flags); |
3217cb42 |
/** |
49bd8e4b |
* Update cur_dts of all streams based on the given timestamp and AVStream. |
3217cb42 |
* |
4f57fa8c |
* Stream ref_st unchanged, others set cur_dts in their native time base.
* Only needed for timestamp wrapping or if (dts not set and pts!=dts). |
3217cb42 |
* @param timestamp new dts expressed in time_base of param ref_st
* @param ref_st reference stream giving time_base of param timestamp
*/ |
22ffac70 |
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); |
3217cb42 |
/** |
49bd8e4b |
* Perform a binary search using read_timestamp(). |
78cb7273 |
* This is not supposed to be called directly by a user application,
* but by demuxers. |
3217cb42 |
* @param target_ts target timestamp in the time base of the given stream
* @param stream_index stream number
*/ |
78cb7273 |
int64_t av_gen_search(AVFormatContext *s, int stream_index,
int64_t target_ts, int64_t pos_min,
int64_t pos_max, int64_t pos_limit,
int64_t ts_min, int64_t ts_max,
int flags, int64_t *ts_ret,
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); |
b754978a |
|
76c56376 |
/**
* media file output
*/ |
25de5958 |
#if FF_API_FORMAT_PARAMETERS
/**
* @deprecated pass the options to avformat_write_header directly.
*/ |
7d727f13 |
attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); |
25de5958 |
#endif |
3217cb42 |
/** |
f3bfe388 |
* Split a URL string into components.
*
* The pointers to buffers for storing individual components may be null,
* in order to ignore that component. Buffers for components not found are
* set to empty strings. If the port is not found, it is set to a negative
* value.
*
* @param proto the buffer for the protocol
* @param proto_size the size of the proto buffer
* @param authorization the buffer for the authorization
* @param authorization_size the size of the authorization buffer
* @param hostname the buffer for the host name
* @param hostname_size the size of the hostname buffer
* @param port_ptr a pointer to store the port number in
* @param path the buffer for the path
* @param path_size the size of the path buffer
* @param url the URL to split
*/
void av_url_split(char *proto, int proto_size,
char *authorization, int authorization_size,
char *hostname, int hostname_size,
int *port_ptr,
char *path, int path_size,
const char *url);
/** |
25de5958 |
* Allocate the stream private data and write the stream header to
* an output media file.
*
* @param s Media file handle, must be allocated with avformat_alloc_context().
* Its oformat field must be set to the desired output format;
* Its pb field must be set to an already openened AVIOContext.
* @param options An AVDictionary filled with AVFormatContext and muxer-private options.
* On return this parameter will be destroyed and replaced with a dict containing
* options that were not found. May be NULL.
*
* @return 0 on success, negative AVERROR on failure.
*
* @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
*/
int avformat_write_header(AVFormatContext *s, AVDictionary **options);
#if FF_API_FORMAT_PARAMETERS
/** |
49bd8e4b |
* Allocate the stream private data and write the stream header to an |
755bfeab |
* output media file. |
438198e7 |
* @note: this sets stream time-bases, if possible to stream->codec->time_base |
12763671 |
* but for some formats it might also be some other time base |
3217cb42 |
*
* @param s media file handle |
4f57fa8c |
* @return 0 if OK, AVERROR_xxx on error |
25de5958 |
*
* @deprecated use avformat_write_header. |
3217cb42 |
*/ |
25de5958 |
attribute_deprecated int av_write_header(AVFormatContext *s);
#endif |
3217cb42 |
/** |
49bd8e4b |
* Write a packet to an output media file. |
3217cb42 |
*
* The packet shall contain one audio or video frame. |
78cb7273 |
* The packet must be correctly interleaved according to the container
* specification, if not then av_interleaved_write_frame must be used. |
3217cb42 |
*
* @param s media file handle |
78cb7273 |
* @param pkt The packet, which contains the stream_index, buf/buf_size,
dts/pts, ... |
4f57fa8c |
* @return < 0 on error, = 0 if OK, 1 if end of stream wanted |
3217cb42 |
*/ |
e928649b |
int av_write_frame(AVFormatContext *s, AVPacket *pkt); |
3217cb42 |
/** |
49bd8e4b |
* Write a packet to an output media file ensuring correct interleaving. |
3217cb42 |
*
* The packet must contain one audio or video frame. |
22e77e44 |
* If the packets are already correctly interleaved, the application should |
90b5b51e |
* call av_write_frame() instead as it is slightly faster. It is also important
* to keep in mind that completely non-interleaved input will need huge amounts
* of memory to interleave with this, so it is preferable to interleave at the
* demuxer level. |
3217cb42 |
*
* @param s media file handle |
78cb7273 |
* @param pkt The packet, which contains the stream_index, buf/buf_size,
dts/pts, ... |
4f57fa8c |
* @return < 0 on error, = 0 if OK, 1 if end of stream wanted |
3217cb42 |
*/ |
3c895fc0 |
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); |
3217cb42 |
/** |
49bd8e4b |
* Interleave a packet per dts in an output media file. |
3217cb42 |
* |
78cb7273 |
* Packets with pkt->destruct == av_destruct_packet will be freed inside this |
22e77e44 |
* function, so they cannot be used after it. Note that calling av_free_packet() |
78cb7273 |
* on them is still safe. |
3217cb42 |
*
* @param s media file handle
* @param out the interleaved packet will be output here |
9a58234f |
* @param pkt the input packet |
3217cb42 |
* @param flush 1 if no further packets are available as input and all
* remaining packets should be output
* @return 1 if a packet was output, 0 if no packet could be output, |
d9526386 |
* < 0 if an error occurred |
3217cb42 |
*/ |
78cb7273 |
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
AVPacket *pkt, int flush); |
e928649b |
|
3217cb42 |
/** |
49bd8e4b |
* Write the stream trailer to an output media file and free the |
2b75bde6 |
* file private data. |
3217cb42 |
* |
dc76fe13 |
* May only be called after a successful call to av_write_header.
* |
3217cb42 |
* @param s media file handle |
4f57fa8c |
* @return 0 if OK, AVERROR_xxx on error |
3217cb42 |
*/ |
b9a281db |
int av_write_trailer(AVFormatContext *s); |
de6d9b64 |
|
0ebf4754 |
#if FF_API_DUMP_FORMAT |
adf94155 |
/**
* @deprecated Deprecated in favor of av_dump_format().
*/ |
0ebf4754 |
attribute_deprecated void dump_format(AVFormatContext *ic,
int index,
const char *url,
int is_output);
#endif
void av_dump_format(AVFormatContext *ic,
int index,
const char *url,
int is_output); |
3217cb42 |
|
40c3fe2c |
#if FF_API_PARSE_DATE |
3217cb42 |
/** |
49bd8e4b |
* Parse datestr and return a corresponding number of microseconds. |
40c3fe2c |
* |
f9436161 |
* @param datestr String representing a date or a duration. |
40c3fe2c |
* See av_parse_time() for the syntax of the provided string.
* @deprecated in favor of av_parse_time() |
3217cb42 |
*/ |
40c3fe2c |
attribute_deprecated |
0c1a9eda |
int64_t parse_date(const char *datestr, int duration); |
40c3fe2c |
#endif |
de6d9b64 |
|
76c56376 |
/**
* Get the current time in microseconds.
*/ |
0c1a9eda |
int64_t av_gettime(void); |
94988531 |
|
1b98107c |
#if FF_API_FIND_INFO_TAG |
3217cb42 |
/** |
1b98107c |
* @deprecated use av_find_info_tag in libavutil instead. |
3217cb42 |
*/ |
1b98107c |
attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
#endif |
de6d9b64 |
|
3217cb42 |
/** |
49bd8e4b |
* Return in 'buf' the path with '%d' replaced by a number. |
4f57fa8c |
* |
3217cb42 |
* Also handles the '%0nd' format where 'n' is the total number
* of digits and '%%'.
*
* @param buf destination buffer
* @param buf_size destination buffer size
* @param path numbered sequence string |
8ea0e802 |
* @param number frame number |
4f57fa8c |
* @return 0 if OK, -1 on format error |
3217cb42 |
*/ |
5c07cf53 |
int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number); |
3217cb42 |
/** |
49bd8e4b |
* Check whether filename actually is a numbered sequence generator. |
3217cb42 |
*
* @param filename possible numbered sequence string |
4f57fa8c |
* @return 1 if a valid numbered sequence string, 0 otherwise |
3217cb42 |
*/ |
5c07cf53 |
int av_filename_number_test(const char *filename); |
96baaa6a |
|
c5388c07 |
/** |
49bd8e4b |
* Generate an SDP for an RTP session. |
c5388c07 |
*
* @param ac array of AVFormatContexts describing the RTP streams. If the
* array is composed by only one context, such context can contain
* multiple AVStreams (one AVStream per RTP stream). Otherwise,
* all the contexts in the array (an AVCodecContext per RTP stream) |
4f57fa8c |
* must contain only one AVStream. |
8767b80f |
* @param n_files number of AVCodecContexts contained in ac |
c234d40b |
* @param buf buffer where the SDP will be stored (must be allocated by
* the caller) |
8767b80f |
* @param size the size of the buffer |
4f57fa8c |
* @return 0 if OK, AVERROR_xxx on error |
c5388c07 |
*/ |
c234d40b |
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); |
c3675dfe |
#if FF_API_SDP_CREATE
attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
#endif |
c5388c07 |
|
1a70d127 |
/** |
49bd8e4b |
* Return a positive value if the given filename has one of the given |
1a70d127 |
* extensions, 0 otherwise.
*
* @param extensions a comma-separated list of filename extensions
*/
int av_match_ext(const char *filename, const char *extensions);
|
98790382 |
#endif /* AVFORMAT_AVFORMAT_H */ |