yading@11
|
1 /*
|
yading@11
|
2 * copyright (c) 2001 Fabrice Bellard
|
yading@11
|
3 *
|
yading@11
|
4 * This file is part of FFmpeg.
|
yading@11
|
5 *
|
yading@11
|
6 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
7 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
8 * License as published by the Free Software Foundation; either
|
yading@11
|
9 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
10 *
|
yading@11
|
11 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
14 * Lesser General Public License for more details.
|
yading@11
|
15 *
|
yading@11
|
16 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
17 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
19 */
|
yading@11
|
20
|
yading@11
|
21 #ifndef AVFORMAT_AVFORMAT_H
|
yading@11
|
22 #define AVFORMAT_AVFORMAT_H
|
yading@11
|
23
|
yading@11
|
24 /**
|
yading@11
|
25 * @file
|
yading@11
|
26 * @ingroup libavf
|
yading@11
|
27 * Main libavformat public API header
|
yading@11
|
28 */
|
yading@11
|
29
|
yading@11
|
30 /**
|
yading@11
|
31 * @defgroup libavf I/O and Muxing/Demuxing Library
|
yading@11
|
32 * @{
|
yading@11
|
33 *
|
yading@11
|
34 * Libavformat (lavf) is a library for dealing with various media container
|
yading@11
|
35 * formats. Its main two purposes are demuxing - i.e. splitting a media file
|
yading@11
|
36 * into component streams, and the reverse process of muxing - writing supplied
|
yading@11
|
37 * data in a specified container format. It also has an @ref lavf_io
|
yading@11
|
38 * "I/O module" which supports a number of protocols for accessing the data (e.g.
|
yading@11
|
39 * file, tcp, http and others). Before using lavf, you need to call
|
yading@11
|
40 * av_register_all() to register all compiled muxers, demuxers and protocols.
|
yading@11
|
41 * Unless you are absolutely sure you won't use libavformat's network
|
yading@11
|
42 * capabilities, you should also call avformat_network_init().
|
yading@11
|
43 *
|
yading@11
|
44 * A supported input format is described by an AVInputFormat struct, conversely
|
yading@11
|
45 * an output format is described by AVOutputFormat. You can iterate over all
|
yading@11
|
46 * registered input/output formats using the av_iformat_next() /
|
yading@11
|
47 * av_oformat_next() functions. The protocols layer is not part of the public
|
yading@11
|
48 * API, so you can only get the names of supported protocols with the
|
yading@11
|
49 * avio_enum_protocols() function.
|
yading@11
|
50 *
|
yading@11
|
51 * Main lavf structure used for both muxing and demuxing is AVFormatContext,
|
yading@11
|
52 * which exports all information about the file being read or written. As with
|
yading@11
|
53 * most Libavformat structures, its size is not part of public ABI, so it cannot be
|
yading@11
|
54 * allocated on stack or directly with av_malloc(). To create an
|
yading@11
|
55 * AVFormatContext, use avformat_alloc_context() (some functions, like
|
yading@11
|
56 * avformat_open_input() might do that for you).
|
yading@11
|
57 *
|
yading@11
|
58 * Most importantly an AVFormatContext contains:
|
yading@11
|
59 * @li the @ref AVFormatContext.iformat "input" or @ref AVFormatContext.oformat
|
yading@11
|
60 * "output" format. It is either autodetected or set by user for input;
|
yading@11
|
61 * always set by user for output.
|
yading@11
|
62 * @li an @ref AVFormatContext.streams "array" of AVStreams, which describe all
|
yading@11
|
63 * elementary streams stored in the file. AVStreams are typically referred to
|
yading@11
|
64 * using their index in this array.
|
yading@11
|
65 * @li an @ref AVFormatContext.pb "I/O context". It is either opened by lavf or
|
yading@11
|
66 * set by user for input, always set by user for output (unless you are dealing
|
yading@11
|
67 * with an AVFMT_NOFILE format).
|
yading@11
|
68 *
|
yading@11
|
69 * @section lavf_options Passing options to (de)muxers
|
yading@11
|
70 * Lavf allows to configure muxers and demuxers using the @ref avoptions
|
yading@11
|
71 * mechanism. Generic (format-independent) libavformat options are provided by
|
yading@11
|
72 * AVFormatContext, they can be examined from a user program by calling
|
yading@11
|
73 * av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass
|
yading@11
|
74 * from avformat_get_class()). Private (format-specific) options are provided by
|
yading@11
|
75 * AVFormatContext.priv_data if and only if AVInputFormat.priv_class /
|
yading@11
|
76 * AVOutputFormat.priv_class of the corresponding format struct is non-NULL.
|
yading@11
|
77 * Further options may be provided by the @ref AVFormatContext.pb "I/O context",
|
yading@11
|
78 * if its AVClass is non-NULL, and the protocols layer. See the discussion on
|
yading@11
|
79 * nesting in @ref avoptions documentation to learn how to access those.
|
yading@11
|
80 *
|
yading@11
|
81 * @defgroup lavf_decoding Demuxing
|
yading@11
|
82 * @{
|
yading@11
|
83 * Demuxers read a media file and split it into chunks of data (@em packets). A
|
yading@11
|
84 * @ref AVPacket "packet" contains one or more encoded frames which belongs to a
|
yading@11
|
85 * single elementary stream. In the lavf API this process is represented by the
|
yading@11
|
86 * avformat_open_input() function for opening a file, av_read_frame() for
|
yading@11
|
87 * reading a single packet and finally avformat_close_input(), which does the
|
yading@11
|
88 * cleanup.
|
yading@11
|
89 *
|
yading@11
|
90 * @section lavf_decoding_open Opening a media file
|
yading@11
|
91 * The minimum information required to open a file is its URL or filename, which
|
yading@11
|
92 * is passed to avformat_open_input(), as in the following code:
|
yading@11
|
93 * @code
|
yading@11
|
94 * const char *url = "in.mp3";
|
yading@11
|
95 * AVFormatContext *s = NULL;
|
yading@11
|
96 * int ret = avformat_open_input(&s, url, NULL, NULL);
|
yading@11
|
97 * if (ret < 0)
|
yading@11
|
98 * abort();
|
yading@11
|
99 * @endcode
|
yading@11
|
100 * The above code attempts to allocate an AVFormatContext, open the
|
yading@11
|
101 * specified file (autodetecting the format) and read the header, exporting the
|
yading@11
|
102 * information stored there into s. Some formats do not have a header or do not
|
yading@11
|
103 * store enough information there, so it is recommended that you call the
|
yading@11
|
104 * avformat_find_stream_info() function which tries to read and decode a few
|
yading@11
|
105 * frames to find missing information.
|
yading@11
|
106 *
|
yading@11
|
107 * In some cases you might want to preallocate an AVFormatContext yourself with
|
yading@11
|
108 * avformat_alloc_context() and do some tweaking on it before passing it to
|
yading@11
|
109 * avformat_open_input(). One such case is when you want to use custom functions
|
yading@11
|
110 * for reading input data instead of lavf internal I/O layer.
|
yading@11
|
111 * To do that, create your own AVIOContext with avio_alloc_context(), passing
|
yading@11
|
112 * your reading callbacks to it. Then set the @em pb field of your
|
yading@11
|
113 * AVFormatContext to newly created AVIOContext.
|
yading@11
|
114 *
|
yading@11
|
115 * Since the format of the opened file is in general not known until after
|
yading@11
|
116 * avformat_open_input() has returned, it is not possible to set demuxer private
|
yading@11
|
117 * options on a preallocated context. Instead, the options should be passed to
|
yading@11
|
118 * avformat_open_input() wrapped in an AVDictionary:
|
yading@11
|
119 * @code
|
yading@11
|
120 * AVDictionary *options = NULL;
|
yading@11
|
121 * av_dict_set(&options, "video_size", "640x480", 0);
|
yading@11
|
122 * av_dict_set(&options, "pixel_format", "rgb24", 0);
|
yading@11
|
123 *
|
yading@11
|
124 * if (avformat_open_input(&s, url, NULL, &options) < 0)
|
yading@11
|
125 * abort();
|
yading@11
|
126 * av_dict_free(&options);
|
yading@11
|
127 * @endcode
|
yading@11
|
128 * This code passes the private options 'video_size' and 'pixel_format' to the
|
yading@11
|
129 * demuxer. They would be necessary for e.g. the rawvideo demuxer, since it
|
yading@11
|
130 * cannot know how to interpret raw video data otherwise. If the format turns
|
yading@11
|
131 * out to be something different than raw video, those options will not be
|
yading@11
|
132 * recognized by the demuxer and therefore will not be applied. Such unrecognized
|
yading@11
|
133 * options are then returned in the options dictionary (recognized options are
|
yading@11
|
134 * consumed). The calling program can handle such unrecognized options as it
|
yading@11
|
135 * wishes, e.g.
|
yading@11
|
136 * @code
|
yading@11
|
137 * AVDictionaryEntry *e;
|
yading@11
|
138 * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
|
yading@11
|
139 * fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
|
yading@11
|
140 * abort();
|
yading@11
|
141 * }
|
yading@11
|
142 * @endcode
|
yading@11
|
143 *
|
yading@11
|
144 * After you have finished reading the file, you must close it with
|
yading@11
|
145 * avformat_close_input(). It will free everything associated with the file.
|
yading@11
|
146 *
|
yading@11
|
147 * @section lavf_decoding_read Reading from an opened file
|
yading@11
|
148 * Reading data from an opened AVFormatContext is done by repeatedly calling
|
yading@11
|
149 * av_read_frame() on it. Each call, if successful, will return an AVPacket
|
yading@11
|
150 * containing encoded data for one AVStream, identified by
|
yading@11
|
151 * AVPacket.stream_index. This packet may be passed straight into the libavcodec
|
yading@11
|
152 * decoding functions avcodec_decode_video2(), avcodec_decode_audio4() or
|
yading@11
|
153 * avcodec_decode_subtitle2() if the caller wishes to decode the data.
|
yading@11
|
154 *
|
yading@11
|
155 * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be
|
yading@11
|
156 * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for
|
yading@11
|
157 * pts/dts, 0 for duration) if the stream does not provide them. The timing
|
yading@11
|
158 * information will be in AVStream.time_base units, i.e. it has to be
|
yading@11
|
159 * multiplied by the timebase to convert them to seconds.
|
yading@11
|
160 *
|
yading@11
|
161 * If AVPacket.buf is set on the returned packet, then the packet is
|
yading@11
|
162 * allocated dynamically and the user may keep it indefinitely.
|
yading@11
|
163 * Otherwise, if AVPacket.buf is NULL, the packet data is backed by a
|
yading@11
|
164 * static storage somewhere inside the demuxer and the packet is only valid
|
yading@11
|
165 * until the next av_read_frame() call or closing the file. If the caller
|
yading@11
|
166 * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy
|
yading@11
|
167 * of it.
|
yading@11
|
168 * In both cases, the packet must be freed with av_free_packet() when it is no
|
yading@11
|
169 * longer needed.
|
yading@11
|
170 *
|
yading@11
|
171 * @section lavf_decoding_seek Seeking
|
yading@11
|
172 * @}
|
yading@11
|
173 *
|
yading@11
|
174 * @defgroup lavf_encoding Muxing
|
yading@11
|
175 * @{
|
yading@11
|
176 * @}
|
yading@11
|
177 *
|
yading@11
|
178 * @defgroup lavf_io I/O Read/Write
|
yading@11
|
179 * @{
|
yading@11
|
180 * @}
|
yading@11
|
181 *
|
yading@11
|
182 * @defgroup lavf_codec Demuxers
|
yading@11
|
183 * @{
|
yading@11
|
184 * @defgroup lavf_codec_native Native Demuxers
|
yading@11
|
185 * @{
|
yading@11
|
186 * @}
|
yading@11
|
187 * @defgroup lavf_codec_wrappers External library wrappers
|
yading@11
|
188 * @{
|
yading@11
|
189 * @}
|
yading@11
|
190 * @}
|
yading@11
|
191 * @defgroup lavf_protos I/O Protocols
|
yading@11
|
192 * @{
|
yading@11
|
193 * @}
|
yading@11
|
194 * @defgroup lavf_internal Internal
|
yading@11
|
195 * @{
|
yading@11
|
196 * @}
|
yading@11
|
197 * @}
|
yading@11
|
198 *
|
yading@11
|
199 */
|
yading@11
|
200
|
yading@11
|
201 #include <time.h>
|
yading@11
|
202 #include <stdio.h> /* FILE */
|
yading@11
|
203 #include "libavcodec/avcodec.h"
|
yading@11
|
204 #include "libavutil/dict.h"
|
yading@11
|
205 #include "libavutil/log.h"
|
yading@11
|
206
|
yading@11
|
207 #include "avio.h"
|
yading@11
|
208 #include "libavformat/version.h"
|
yading@11
|
209
|
yading@11
|
210 struct AVFormatContext;
|
yading@11
|
211
|
yading@11
|
212
|
yading@11
|
213 /**
|
yading@11
|
214 * @defgroup metadata_api Public Metadata API
|
yading@11
|
215 * @{
|
yading@11
|
216 * @ingroup libavf
|
yading@11
|
217 * The metadata API allows libavformat to export metadata tags to a client
|
yading@11
|
218 * application when demuxing. Conversely it allows a client application to
|
yading@11
|
219 * set metadata when muxing.
|
yading@11
|
220 *
|
yading@11
|
221 * Metadata is exported or set as pairs of key/value strings in the 'metadata'
|
yading@11
|
222 * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs
|
yading@11
|
223 * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,
|
yading@11
|
224 * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata
|
yading@11
|
225 * exported by demuxers isn't checked to be valid UTF-8 in most cases.
|
yading@11
|
226 *
|
yading@11
|
227 * Important concepts to keep in mind:
|
yading@11
|
228 * - Keys are unique; there can never be 2 tags with the same key. This is
|
yading@11
|
229 * also meant semantically, i.e., a demuxer should not knowingly produce
|
yading@11
|
230 * several keys that are literally different but semantically identical.
|
yading@11
|
231 * E.g., key=Author5, key=Author6. In this example, all authors must be
|
yading@11
|
232 * placed in the same tag.
|
yading@11
|
233 * - Metadata is flat, not hierarchical; there are no subtags. If you
|
yading@11
|
234 * want to store, e.g., the email address of the child of producer Alice
|
yading@11
|
235 * and actor Bob, that could have key=alice_and_bobs_childs_email_address.
|
yading@11
|
236 * - Several modifiers can be applied to the tag name. This is done by
|
yading@11
|
237 * appending a dash character ('-') and the modifier name in the order
|
yading@11
|
238 * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.
|
yading@11
|
239 * - language -- a tag whose value is localized for a particular language
|
yading@11
|
240 * is appended with the ISO 639-2/B 3-letter language code.
|
yading@11
|
241 * For example: Author-ger=Michael, Author-eng=Mike
|
yading@11
|
242 * The original/default language is in the unqualified "Author" tag.
|
yading@11
|
243 * A demuxer should set a default if it sets any translated tag.
|
yading@11
|
244 * - sorting -- a modified version of a tag that should be used for
|
yading@11
|
245 * sorting will have '-sort' appended. E.g. artist="The Beatles",
|
yading@11
|
246 * artist-sort="Beatles, The".
|
yading@11
|
247 *
|
yading@11
|
248 * - Demuxers attempt to export metadata in a generic format, however tags
|
yading@11
|
249 * with no generic equivalents are left as they are stored in the container.
|
yading@11
|
250 * Follows a list of generic tag names:
|
yading@11
|
251 *
|
yading@11
|
252 @verbatim
|
yading@11
|
253 album -- name of the set this work belongs to
|
yading@11
|
254 album_artist -- main creator of the set/album, if different from artist.
|
yading@11
|
255 e.g. "Various Artists" for compilation albums.
|
yading@11
|
256 artist -- main creator of the work
|
yading@11
|
257 comment -- any additional description of the file.
|
yading@11
|
258 composer -- who composed the work, if different from artist.
|
yading@11
|
259 copyright -- name of copyright holder.
|
yading@11
|
260 creation_time-- date when the file was created, preferably in ISO 8601.
|
yading@11
|
261 date -- date when the work was created, preferably in ISO 8601.
|
yading@11
|
262 disc -- number of a subset, e.g. disc in a multi-disc collection.
|
yading@11
|
263 encoder -- name/settings of the software/hardware that produced the file.
|
yading@11
|
264 encoded_by -- person/group who created the file.
|
yading@11
|
265 filename -- original name of the file.
|
yading@11
|
266 genre -- <self-evident>.
|
yading@11
|
267 language -- main language in which the work is performed, preferably
|
yading@11
|
268 in ISO 639-2 format. Multiple languages can be specified by
|
yading@11
|
269 separating them with commas.
|
yading@11
|
270 performer -- artist who performed the work, if different from artist.
|
yading@11
|
271 E.g for "Also sprach Zarathustra", artist would be "Richard
|
yading@11
|
272 Strauss" and performer "London Philharmonic Orchestra".
|
yading@11
|
273 publisher -- name of the label/publisher.
|
yading@11
|
274 service_name -- name of the service in broadcasting (channel name).
|
yading@11
|
275 service_provider -- name of the service provider in broadcasting.
|
yading@11
|
276 title -- name of the work.
|
yading@11
|
277 track -- number of this work in the set, can be in form current/total.
|
yading@11
|
278 variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
|
yading@11
|
279 @endverbatim
|
yading@11
|
280 *
|
yading@11
|
281 * Look in the examples section for an application example how to use the Metadata API.
|
yading@11
|
282 *
|
yading@11
|
283 * @}
|
yading@11
|
284 */
|
yading@11
|
285
|
yading@11
|
286 /* packet functions */
|
yading@11
|
287
|
yading@11
|
288
|
yading@11
|
289 /**
|
yading@11
|
290 * Allocate and read the payload of a packet and initialize its
|
yading@11
|
291 * fields with default values.
|
yading@11
|
292 *
|
yading@11
|
293 * @param pkt packet
|
yading@11
|
294 * @param size desired payload size
|
yading@11
|
295 * @return >0 (read size) if OK, AVERROR_xxx otherwise
|
yading@11
|
296 */
|
yading@11
|
297 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
|
yading@11
|
298
|
yading@11
|
299
|
yading@11
|
300 /**
|
yading@11
|
301 * Read data and append it to the current content of the AVPacket.
|
yading@11
|
302 * If pkt->size is 0 this is identical to av_get_packet.
|
yading@11
|
303 * Note that this uses av_grow_packet and thus involves a realloc
|
yading@11
|
304 * which is inefficient. Thus this function should only be used
|
yading@11
|
305 * when there is no reasonable way to know (an upper bound of)
|
yading@11
|
306 * the final size.
|
yading@11
|
307 *
|
yading@11
|
308 * @param pkt packet
|
yading@11
|
309 * @param size amount of data to read
|
yading@11
|
310 * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
|
yading@11
|
311 * will not be lost even if an error occurs.
|
yading@11
|
312 */
|
yading@11
|
313 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
|
yading@11
|
314
|
yading@11
|
315 /*************************************************/
|
yading@11
|
316 /* fractional numbers for exact pts handling */
|
yading@11
|
317
|
yading@11
|
318 /**
|
yading@11
|
319 * The exact value of the fractional number is: 'val + num / den'.
|
yading@11
|
320 * num is assumed to be 0 <= num < den.
|
yading@11
|
321 */
|
yading@11
|
322 typedef struct AVFrac {
|
yading@11
|
323 int64_t val, num, den;
|
yading@11
|
324 } AVFrac;
|
yading@11
|
325
|
yading@11
|
326 /*************************************************/
|
yading@11
|
327 /* input/output formats */
|
yading@11
|
328
|
yading@11
|
329 struct AVCodecTag;
|
yading@11
|
330
|
yading@11
|
331 /**
|
yading@11
|
332 * This structure contains the data a format has to probe a file.
|
yading@11
|
333 */
|
yading@11
|
334 typedef struct AVProbeData {
|
yading@11
|
335 const char *filename;
|
yading@11
|
336 unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
|
yading@11
|
337 int buf_size; /**< Size of buf except extra allocated bytes */
|
yading@11
|
338 } AVProbeData;
|
yading@11
|
339
|
yading@11
|
340 #define AVPROBE_SCORE_MAX 100 ///< maximum score, half of that is used for file-extension-based detection
|
yading@11
|
341 #define AVPROBE_SCORE_RETRY (AVPROBE_SCORE_MAX/4)
|
yading@11
|
342 #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer
|
yading@11
|
343
|
yading@11
|
344 /// Demuxer will use avio_open, no opened file should be provided by the caller.
|
yading@11
|
345 #define AVFMT_NOFILE 0x0001
|
yading@11
|
346 #define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */
|
yading@11
|
347 #define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */
|
yading@11
|
348 #define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for
|
yading@11
|
349 raw picture data. */
|
yading@11
|
350 #define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */
|
yading@11
|
351 #define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */
|
yading@11
|
352 #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
|
yading@11
|
353 #define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */
|
yading@11
|
354 #define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */
|
yading@11
|
355 #define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */
|
yading@11
|
356 #define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */
|
yading@11
|
357 #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */
|
yading@11
|
358 #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */
|
yading@11
|
359 #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */
|
yading@11
|
360 #define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */
|
yading@11
|
361 #if LIBAVFORMAT_VERSION_MAJOR <= 54
|
yading@11
|
362 #define AVFMT_TS_NONSTRICT 0x8020000 //we try to be compatible to the ABIs of ffmpeg and major forks
|
yading@11
|
363 #else
|
yading@11
|
364 #define AVFMT_TS_NONSTRICT 0x20000
|
yading@11
|
365 #endif
|
yading@11
|
366 /**< Format does not require strictly
|
yading@11
|
367 increasing timestamps, but they must
|
yading@11
|
368 still be monotonic */
|
yading@11
|
369
|
yading@11
|
370 #define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */
|
yading@11
|
371
|
yading@11
|
372 /**
|
yading@11
|
373 * @addtogroup lavf_encoding
|
yading@11
|
374 * @{
|
yading@11
|
375 */
|
yading@11
|
376 typedef struct AVOutputFormat {
|
yading@11
|
377 const char *name;
|
yading@11
|
378 /**
|
yading@11
|
379 * Descriptive name for the format, meant to be more human-readable
|
yading@11
|
380 * than name. You should use the NULL_IF_CONFIG_SMALL() macro
|
yading@11
|
381 * to define it.
|
yading@11
|
382 */
|
yading@11
|
383 const char *long_name;
|
yading@11
|
384 const char *mime_type;
|
yading@11
|
385 const char *extensions; /**< comma-separated filename extensions */
|
yading@11
|
386 /* output support */
|
yading@11
|
387 enum AVCodecID audio_codec; /**< default audio codec */
|
yading@11
|
388 enum AVCodecID video_codec; /**< default video codec */
|
yading@11
|
389 enum AVCodecID subtitle_codec; /**< default subtitle codec */
|
yading@11
|
390 /**
|
yading@11
|
391 * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE,
|
yading@11
|
392 * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
|
yading@11
|
393 * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
|
yading@11
|
394 * AVFMT_TS_NONSTRICT
|
yading@11
|
395 */
|
yading@11
|
396 int flags;
|
yading@11
|
397
|
yading@11
|
398 /**
|
yading@11
|
399 * List of supported codec_id-codec_tag pairs, ordered by "better
|
yading@11
|
400 * choice first". The arrays are all terminated by AV_CODEC_ID_NONE.
|
yading@11
|
401 */
|
yading@11
|
402 const struct AVCodecTag * const *codec_tag;
|
yading@11
|
403
|
yading@11
|
404
|
yading@11
|
405 const AVClass *priv_class; ///< AVClass for the private context
|
yading@11
|
406
|
yading@11
|
407 /*****************************************************************
|
yading@11
|
408 * No fields below this line are part of the public API. They
|
yading@11
|
409 * may not be used outside of libavformat and can be changed and
|
yading@11
|
410 * removed at will.
|
yading@11
|
411 * New public fields should be added right above.
|
yading@11
|
412 *****************************************************************
|
yading@11
|
413 */
|
yading@11
|
414 struct AVOutputFormat *next;
|
yading@11
|
415 /**
|
yading@11
|
416 * size of private data so that it can be allocated in the wrapper
|
yading@11
|
417 */
|
yading@11
|
418 int priv_data_size;
|
yading@11
|
419
|
yading@11
|
420 int (*write_header)(struct AVFormatContext *);
|
yading@11
|
421 /**
|
yading@11
|
422 * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
|
yading@11
|
423 * pkt can be NULL in order to flush data buffered in the muxer.
|
yading@11
|
424 * When flushing, return 0 if there still is more data to flush,
|
yading@11
|
425 * or 1 if everything was flushed and there is no more buffered
|
yading@11
|
426 * data.
|
yading@11
|
427 */
|
yading@11
|
428 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
|
yading@11
|
429 int (*write_trailer)(struct AVFormatContext *);
|
yading@11
|
430 /**
|
yading@11
|
431 * Currently only used to set pixel format if not YUV420P.
|
yading@11
|
432 */
|
yading@11
|
433 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
|
yading@11
|
434 AVPacket *in, int flush);
|
yading@11
|
435 /**
|
yading@11
|
436 * Test if the given codec can be stored in this container.
|
yading@11
|
437 *
|
yading@11
|
438 * @return 1 if the codec is supported, 0 if it is not.
|
yading@11
|
439 * A negative number if unknown.
|
yading@11
|
440 * MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC
|
yading@11
|
441 */
|
yading@11
|
442 int (*query_codec)(enum AVCodecID id, int std_compliance);
|
yading@11
|
443
|
yading@11
|
444 void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
|
yading@11
|
445 int64_t *dts, int64_t *wall);
|
yading@11
|
446 } AVOutputFormat;
|
yading@11
|
447 /**
|
yading@11
|
448 * @}
|
yading@11
|
449 */
|
yading@11
|
450
|
yading@11
|
451 /**
|
yading@11
|
452 * @addtogroup lavf_decoding
|
yading@11
|
453 * @{
|
yading@11
|
454 */
|
yading@11
|
455 typedef struct AVInputFormat {
|
yading@11
|
456 /**
|
yading@11
|
457 * A comma separated list of short names for the format. New names
|
yading@11
|
458 * may be appended with a minor bump.
|
yading@11
|
459 */
|
yading@11
|
460 const char *name;
|
yading@11
|
461
|
yading@11
|
462 /**
|
yading@11
|
463 * Descriptive name for the format, meant to be more human-readable
|
yading@11
|
464 * than name. You should use the NULL_IF_CONFIG_SMALL() macro
|
yading@11
|
465 * to define it.
|
yading@11
|
466 */
|
yading@11
|
467 const char *long_name;
|
yading@11
|
468
|
yading@11
|
469 /**
|
yading@11
|
470 * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
|
yading@11
|
471 * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
|
yading@11
|
472 * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
|
yading@11
|
473 */
|
yading@11
|
474 int flags;
|
yading@11
|
475
|
yading@11
|
476 /**
|
yading@11
|
477 * If extensions are defined, then no probe is done. You should
|
yading@11
|
478 * usually not use extension format guessing because it is not
|
yading@11
|
479 * reliable enough
|
yading@11
|
480 */
|
yading@11
|
481 const char *extensions;
|
yading@11
|
482
|
yading@11
|
483 const struct AVCodecTag * const *codec_tag;
|
yading@11
|
484
|
yading@11
|
485 const AVClass *priv_class; ///< AVClass for the private context
|
yading@11
|
486
|
yading@11
|
487 /*****************************************************************
|
yading@11
|
488 * No fields below this line are part of the public API. They
|
yading@11
|
489 * may not be used outside of libavformat and can be changed and
|
yading@11
|
490 * removed at will.
|
yading@11
|
491 * New public fields should be added right above.
|
yading@11
|
492 *****************************************************************
|
yading@11
|
493 */
|
yading@11
|
494 struct AVInputFormat *next;
|
yading@11
|
495
|
yading@11
|
496 /**
|
yading@11
|
497 * Raw demuxers store their codec ID here.
|
yading@11
|
498 */
|
yading@11
|
499 int raw_codec_id;
|
yading@11
|
500
|
yading@11
|
501 /**
|
yading@11
|
502 * Size of private data so that it can be allocated in the wrapper.
|
yading@11
|
503 */
|
yading@11
|
504 int priv_data_size;
|
yading@11
|
505
|
yading@11
|
506 /**
|
yading@11
|
507 * Tell if a given file has a chance of being parsed as this format.
|
yading@11
|
508 * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
|
yading@11
|
509 * big so you do not have to check for that unless you need more.
|
yading@11
|
510 */
|
yading@11
|
511 int (*read_probe)(AVProbeData *);
|
yading@11
|
512
|
yading@11
|
513 /**
|
yading@11
|
514 * Read the format header and initialize the AVFormatContext
|
yading@11
|
515 * structure. Return 0 if OK. Only used in raw format right
|
yading@11
|
516 * now. 'avformat_new_stream' should be called to create new streams.
|
yading@11
|
517 */
|
yading@11
|
518 int (*read_header)(struct AVFormatContext *);
|
yading@11
|
519
|
yading@11
|
520 /**
|
yading@11
|
521 * Read one packet and put it in 'pkt'. pts and flags are also
|
yading@11
|
522 * set. 'avformat_new_stream' can be called only if the flag
|
yading@11
|
523 * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a
|
yading@11
|
524 * background thread).
|
yading@11
|
525 * @return 0 on success, < 0 on error.
|
yading@11
|
526 * When returning an error, pkt must not have been allocated
|
yading@11
|
527 * or must be freed before returning
|
yading@11
|
528 */
|
yading@11
|
529 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
|
yading@11
|
530
|
yading@11
|
531 /**
|
yading@11
|
532 * Close the stream. The AVFormatContext and AVStreams are not
|
yading@11
|
533 * freed by this function
|
yading@11
|
534 */
|
yading@11
|
535 int (*read_close)(struct AVFormatContext *);
|
yading@11
|
536
|
yading@11
|
537 /**
|
yading@11
|
538 * Seek to a given timestamp relative to the frames in
|
yading@11
|
539 * stream component stream_index.
|
yading@11
|
540 * @param stream_index Must not be -1.
|
yading@11
|
541 * @param flags Selects which direction should be preferred if no exact
|
yading@11
|
542 * match is available.
|
yading@11
|
543 * @return >= 0 on success (but not necessarily the new offset)
|
yading@11
|
544 */
|
yading@11
|
545 int (*read_seek)(struct AVFormatContext *,
|
yading@11
|
546 int stream_index, int64_t timestamp, int flags);
|
yading@11
|
547
|
yading@11
|
548 /**
|
yading@11
|
549 * Get the next timestamp in stream[stream_index].time_base units.
|
yading@11
|
550 * @return the timestamp or AV_NOPTS_VALUE if an error occurred
|
yading@11
|
551 */
|
yading@11
|
552 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
|
yading@11
|
553 int64_t *pos, int64_t pos_limit);
|
yading@11
|
554
|
yading@11
|
555 /**
|
yading@11
|
556 * Start/resume playing - only meaningful if using a network-based format
|
yading@11
|
557 * (RTSP).
|
yading@11
|
558 */
|
yading@11
|
559 int (*read_play)(struct AVFormatContext *);
|
yading@11
|
560
|
yading@11
|
561 /**
|
yading@11
|
562 * Pause playing - only meaningful if using a network-based format
|
yading@11
|
563 * (RTSP).
|
yading@11
|
564 */
|
yading@11
|
565 int (*read_pause)(struct AVFormatContext *);
|
yading@11
|
566
|
yading@11
|
567 /**
|
yading@11
|
568 * Seek to timestamp ts.
|
yading@11
|
569 * Seeking will be done so that the point from which all active streams
|
yading@11
|
570 * can be presented successfully will be closest to ts and within min/max_ts.
|
yading@11
|
571 * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
|
yading@11
|
572 */
|
yading@11
|
573 int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
|
yading@11
|
574 } AVInputFormat;
|
yading@11
|
575 /**
|
yading@11
|
576 * @}
|
yading@11
|
577 */
|
yading@11
|
578
|
yading@11
|
579 enum AVStreamParseType {
|
yading@11
|
580 AVSTREAM_PARSE_NONE,
|
yading@11
|
581 AVSTREAM_PARSE_FULL, /**< full parsing and repack */
|
yading@11
|
582 AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */
|
yading@11
|
583 AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */
|
yading@11
|
584 AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */
|
yading@11
|
585 AVSTREAM_PARSE_FULL_RAW=MKTAG(0,'R','A','W'), /**< full parsing and repack with timestamp and position generation by parser for raw
|
yading@11
|
586 this assumes that each packet in the file contains no demuxer level headers and
|
yading@11
|
587 just codec level data, otherwise position generation would fail */
|
yading@11
|
588 };
|
yading@11
|
589
|
yading@11
|
590 typedef struct AVIndexEntry {
|
yading@11
|
591 int64_t pos;
|
yading@11
|
592 int64_t timestamp; /**<
|
yading@11
|
593 * Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are available
|
yading@11
|
594 * when seeking to this entry. That means preferable PTS on keyframe based formats.
|
yading@11
|
595 * But demuxers can choose to store a different timestamp, if it is more convenient for the implementation or nothing better
|
yading@11
|
596 * is known
|
yading@11
|
597 */
|
yading@11
|
598 #define AVINDEX_KEYFRAME 0x0001
|
yading@11
|
599 int flags:2;
|
yading@11
|
600 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).
|
yading@11
|
601 int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
|
yading@11
|
602 } AVIndexEntry;
|
yading@11
|
603
|
yading@11
|
604 #define AV_DISPOSITION_DEFAULT 0x0001
|
yading@11
|
605 #define AV_DISPOSITION_DUB 0x0002
|
yading@11
|
606 #define AV_DISPOSITION_ORIGINAL 0x0004
|
yading@11
|
607 #define AV_DISPOSITION_COMMENT 0x0008
|
yading@11
|
608 #define AV_DISPOSITION_LYRICS 0x0010
|
yading@11
|
609 #define AV_DISPOSITION_KARAOKE 0x0020
|
yading@11
|
610
|
yading@11
|
611 /**
|
yading@11
|
612 * Track should be used during playback by default.
|
yading@11
|
613 * Useful for subtitle track that should be displayed
|
yading@11
|
614 * even when user did not explicitly ask for subtitles.
|
yading@11
|
615 */
|
yading@11
|
616 #define AV_DISPOSITION_FORCED 0x0040
|
yading@11
|
617 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */
|
yading@11
|
618 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */
|
yading@11
|
619 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */
|
yading@11
|
620 /**
|
yading@11
|
621 * The stream is stored in the file as an attached picture/"cover art" (e.g.
|
yading@11
|
622 * APIC frame in ID3v2). The single packet associated with it will be returned
|
yading@11
|
623 * among the first few packets read from the file unless seeking takes place.
|
yading@11
|
624 * It can also be accessed at any time in AVStream.attached_pic.
|
yading@11
|
625 */
|
yading@11
|
626 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
|
yading@11
|
627
|
yading@11
|
628 /**
|
yading@11
|
629 * Options for behavior on timestamp wrap detection.
|
yading@11
|
630 */
|
yading@11
|
631 #define AV_PTS_WRAP_IGNORE 0 ///< ignore the wrap
|
yading@11
|
632 #define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection
|
yading@11
|
633 #define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection
|
yading@11
|
634
|
yading@11
|
635 /**
|
yading@11
|
636 * Stream structure.
|
yading@11
|
637 * New fields can be added to the end with minor version bumps.
|
yading@11
|
638 * Removal, reordering and changes to existing fields require a major
|
yading@11
|
639 * version bump.
|
yading@11
|
640 * sizeof(AVStream) must not be used outside libav*.
|
yading@11
|
641 */
|
yading@11
|
642 typedef struct AVStream {
|
yading@11
|
643 int index; /**< stream index in AVFormatContext */
|
yading@11
|
644 /**
|
yading@11
|
645 * Format-specific stream ID.
|
yading@11
|
646 * decoding: set by libavformat
|
yading@11
|
647 * encoding: set by the user, replaced by libavformat if left unset
|
yading@11
|
648 */
|
yading@11
|
649 int id;
|
yading@11
|
650 /**
|
yading@11
|
651 * Codec context associated with this stream. Allocated and freed by
|
yading@11
|
652 * libavformat.
|
yading@11
|
653 *
|
yading@11
|
654 * - decoding: The demuxer exports codec information stored in the headers
|
yading@11
|
655 * here.
|
yading@11
|
656 * - encoding: The user sets codec information, the muxer writes it to the
|
yading@11
|
657 * output. Mandatory fields as specified in AVCodecContext
|
yading@11
|
658 * documentation must be set even if this AVCodecContext is
|
yading@11
|
659 * not actually used for encoding.
|
yading@11
|
660 */
|
yading@11
|
661 AVCodecContext *codec;
|
yading@11
|
662 void *priv_data;
|
yading@11
|
663
|
yading@11
|
664 /**
|
yading@11
|
665 * encoding: pts generation when outputting stream
|
yading@11
|
666 */
|
yading@11
|
667 struct AVFrac pts;
|
yading@11
|
668
|
yading@11
|
669 /**
|
yading@11
|
670 * This is the fundamental unit of time (in seconds) in terms
|
yading@11
|
671 * of which frame timestamps are represented.
|
yading@11
|
672 *
|
yading@11
|
673 * decoding: set by libavformat
|
yading@11
|
674 * encoding: set by libavformat in avformat_write_header. The muxer may use the
|
yading@11
|
675 * user-provided value of @ref AVCodecContext.time_base "codec->time_base"
|
yading@11
|
676 * as a hint.
|
yading@11
|
677 */
|
yading@11
|
678 AVRational time_base;
|
yading@11
|
679
|
yading@11
|
680 /**
|
yading@11
|
681 * Decoding: pts of the first frame of the stream in presentation order, in stream time base.
|
yading@11
|
682 * Only set this if you are absolutely 100% sure that the value you set
|
yading@11
|
683 * it to really is the pts of the first frame.
|
yading@11
|
684 * This may be undefined (AV_NOPTS_VALUE).
|
yading@11
|
685 * @note The ASF header does NOT contain a correct start_time the ASF
|
yading@11
|
686 * demuxer must NOT set this.
|
yading@11
|
687 */
|
yading@11
|
688 int64_t start_time;
|
yading@11
|
689
|
yading@11
|
690 /**
|
yading@11
|
691 * Decoding: duration of the stream, in stream time base.
|
yading@11
|
692 * If a source file does not specify a duration, but does specify
|
yading@11
|
693 * a bitrate, this value will be estimated from bitrate and file size.
|
yading@11
|
694 */
|
yading@11
|
695 int64_t duration;
|
yading@11
|
696
|
yading@11
|
697 int64_t nb_frames; ///< number of frames in this stream if known or 0
|
yading@11
|
698
|
yading@11
|
699 int disposition; /**< AV_DISPOSITION_* bit field */
|
yading@11
|
700
|
yading@11
|
701 enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
|
yading@11
|
702
|
yading@11
|
703 /**
|
yading@11
|
704 * sample aspect ratio (0 if unknown)
|
yading@11
|
705 * - encoding: Set by user.
|
yading@11
|
706 * - decoding: Set by libavformat.
|
yading@11
|
707 */
|
yading@11
|
708 AVRational sample_aspect_ratio;
|
yading@11
|
709
|
yading@11
|
710 AVDictionary *metadata;
|
yading@11
|
711
|
yading@11
|
712 /**
|
yading@11
|
713 * Average framerate
|
yading@11
|
714 */
|
yading@11
|
715 AVRational avg_frame_rate;
|
yading@11
|
716
|
yading@11
|
717 /**
|
yading@11
|
718 * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet
|
yading@11
|
719 * will contain the attached picture.
|
yading@11
|
720 *
|
yading@11
|
721 * decoding: set by libavformat, must not be modified by the caller.
|
yading@11
|
722 * encoding: unused
|
yading@11
|
723 */
|
yading@11
|
724 AVPacket attached_pic;
|
yading@11
|
725
|
yading@11
|
726 /**
|
yading@11
|
727 * Real base framerate of the stream.
|
yading@11
|
728 * This is the lowest framerate with which all timestamps can be
|
yading@11
|
729 * represented accurately (it is the least common multiple of all
|
yading@11
|
730 * framerates in the stream). Note, this value is just a guess!
|
yading@11
|
731 * For example, if the time base is 1/90000 and all frames have either
|
yading@11
|
732 * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
|
yading@11
|
733 *
|
yading@11
|
734 * Code outside avformat should access this field using:
|
yading@11
|
735 * av_stream_get/set_r_frame_rate(stream)
|
yading@11
|
736 */
|
yading@11
|
737 AVRational r_frame_rate;
|
yading@11
|
738
|
yading@11
|
739 /*****************************************************************
|
yading@11
|
740 * All fields below this line are not part of the public API. They
|
yading@11
|
741 * may not be used outside of libavformat and can be changed and
|
yading@11
|
742 * removed at will.
|
yading@11
|
743 * New public fields should be added right above.
|
yading@11
|
744 *****************************************************************
|
yading@11
|
745 */
|
yading@11
|
746
|
yading@11
|
747 /**
|
yading@11
|
748 * Stream information used internally by av_find_stream_info()
|
yading@11
|
749 */
|
yading@11
|
750 #define MAX_STD_TIMEBASES (60*12+6)
|
yading@11
|
751 struct {
|
yading@11
|
752 int64_t last_dts;
|
yading@11
|
753 int64_t duration_gcd;
|
yading@11
|
754 int duration_count;
|
yading@11
|
755 double (*duration_error)[2][MAX_STD_TIMEBASES];
|
yading@11
|
756 int64_t codec_info_duration;
|
yading@11
|
757 int64_t codec_info_duration_fields;
|
yading@11
|
758 int found_decoder;
|
yading@11
|
759
|
yading@11
|
760 int64_t last_duration;
|
yading@11
|
761
|
yading@11
|
762 /**
|
yading@11
|
763 * Those are used for average framerate estimation.
|
yading@11
|
764 */
|
yading@11
|
765 int64_t fps_first_dts;
|
yading@11
|
766 int fps_first_dts_idx;
|
yading@11
|
767 int64_t fps_last_dts;
|
yading@11
|
768 int fps_last_dts_idx;
|
yading@11
|
769
|
yading@11
|
770 } *info;
|
yading@11
|
771
|
yading@11
|
772 int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
|
yading@11
|
773
|
yading@11
|
774 // Timestamp generation support:
|
yading@11
|
775 /**
|
yading@11
|
776 * Timestamp corresponding to the last dts sync point.
|
yading@11
|
777 *
|
yading@11
|
778 * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
|
yading@11
|
779 * a DTS is received from the underlying container. Otherwise set to
|
yading@11
|
780 * AV_NOPTS_VALUE by default.
|
yading@11
|
781 */
|
yading@11
|
782 int64_t reference_dts;
|
yading@11
|
783 int64_t first_dts;
|
yading@11
|
784 int64_t cur_dts;
|
yading@11
|
785 int64_t last_IP_pts;
|
yading@11
|
786 int last_IP_duration;
|
yading@11
|
787
|
yading@11
|
788 /**
|
yading@11
|
789 * Number of packets to buffer for codec probing
|
yading@11
|
790 */
|
yading@11
|
791 #define MAX_PROBE_PACKETS 2500
|
yading@11
|
792 int probe_packets;
|
yading@11
|
793
|
yading@11
|
794 /**
|
yading@11
|
795 * Number of frames that have been demuxed during av_find_stream_info()
|
yading@11
|
796 */
|
yading@11
|
797 int codec_info_nb_frames;
|
yading@11
|
798
|
yading@11
|
799 /**
|
yading@11
|
800 * Stream Identifier
|
yading@11
|
801 * This is the MPEG-TS stream identifier +1
|
yading@11
|
802 * 0 means unknown
|
yading@11
|
803 */
|
yading@11
|
804 int stream_identifier;
|
yading@11
|
805
|
yading@11
|
806 int64_t interleaver_chunk_size;
|
yading@11
|
807 int64_t interleaver_chunk_duration;
|
yading@11
|
808
|
yading@11
|
809 /* av_read_frame() support */
|
yading@11
|
810 enum AVStreamParseType need_parsing;
|
yading@11
|
811 struct AVCodecParserContext *parser;
|
yading@11
|
812
|
yading@11
|
813 /**
|
yading@11
|
814 * last packet in packet_buffer for this stream when muxing.
|
yading@11
|
815 */
|
yading@11
|
816 struct AVPacketList *last_in_packet_buffer;
|
yading@11
|
817 AVProbeData probe_data;
|
yading@11
|
818 #define MAX_REORDER_DELAY 16
|
yading@11
|
819 int64_t pts_buffer[MAX_REORDER_DELAY+1];
|
yading@11
|
820
|
yading@11
|
821 AVIndexEntry *index_entries; /**< Only used if the format does not
|
yading@11
|
822 support seeking natively. */
|
yading@11
|
823 int nb_index_entries;
|
yading@11
|
824 unsigned int index_entries_allocated_size;
|
yading@11
|
825
|
yading@11
|
826 /**
|
yading@11
|
827 * stream probing state
|
yading@11
|
828 * -1 -> probing finished
|
yading@11
|
829 * 0 -> no probing requested
|
yading@11
|
830 * rest -> perform probing with request_probe being the minimum score to accept.
|
yading@11
|
831 * NOT PART OF PUBLIC API
|
yading@11
|
832 */
|
yading@11
|
833 int request_probe;
|
yading@11
|
834 /**
|
yading@11
|
835 * Indicates that everything up to the next keyframe
|
yading@11
|
836 * should be discarded.
|
yading@11
|
837 */
|
yading@11
|
838 int skip_to_keyframe;
|
yading@11
|
839
|
yading@11
|
840 /**
|
yading@11
|
841 * Number of samples to skip at the start of the frame decoded from the next packet.
|
yading@11
|
842 */
|
yading@11
|
843 int skip_samples;
|
yading@11
|
844
|
yading@11
|
845 /**
|
yading@11
|
846 * Number of internally decoded frames, used internally in libavformat, do not access
|
yading@11
|
847 * its lifetime differs from info which is why it is not in that structure.
|
yading@11
|
848 */
|
yading@11
|
849 int nb_decoded_frames;
|
yading@11
|
850
|
yading@11
|
851 /**
|
yading@11
|
852 * Timestamp offset added to timestamps before muxing
|
yading@11
|
853 * NOT PART OF PUBLIC API
|
yading@11
|
854 */
|
yading@11
|
855 int64_t mux_ts_offset;
|
yading@11
|
856
|
yading@11
|
857 /**
|
yading@11
|
858 * Internal data to check for wrapping of the time stamp
|
yading@11
|
859 */
|
yading@11
|
860 int64_t pts_wrap_reference;
|
yading@11
|
861
|
yading@11
|
862 /**
|
yading@11
|
863 * Options for behavior, when a wrap is detected.
|
yading@11
|
864 *
|
yading@11
|
865 * Defined by AV_PTS_WRAP_ values.
|
yading@11
|
866 *
|
yading@11
|
867 * If correction is enabled, there are two possibilities:
|
yading@11
|
868 * If the first time stamp is near the wrap point, the wrap offset
|
yading@11
|
869 * will be subtracted, which will create negative time stamps.
|
yading@11
|
870 * Otherwise the offset will be added.
|
yading@11
|
871 */
|
yading@11
|
872 int pts_wrap_behavior;
|
yading@11
|
873
|
yading@11
|
874 } AVStream;
|
yading@11
|
875
|
yading@11
|
876 AVRational av_stream_get_r_frame_rate(const AVStream *s);
|
yading@11
|
877 void av_stream_set_r_frame_rate(AVStream *s, AVRational r);
|
yading@11
|
878
|
yading@11
|
879 #define AV_PROGRAM_RUNNING 1
|
yading@11
|
880
|
yading@11
|
881 /**
|
yading@11
|
882 * New fields can be added to the end with minor version bumps.
|
yading@11
|
883 * Removal, reordering and changes to existing fields require a major
|
yading@11
|
884 * version bump.
|
yading@11
|
885 * sizeof(AVProgram) must not be used outside libav*.
|
yading@11
|
886 */
|
yading@11
|
887 typedef struct AVProgram {
|
yading@11
|
888 int id;
|
yading@11
|
889 int flags;
|
yading@11
|
890 enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
|
yading@11
|
891 unsigned int *stream_index;
|
yading@11
|
892 unsigned int nb_stream_indexes;
|
yading@11
|
893 AVDictionary *metadata;
|
yading@11
|
894
|
yading@11
|
895 int program_num;
|
yading@11
|
896 int pmt_pid;
|
yading@11
|
897 int pcr_pid;
|
yading@11
|
898
|
yading@11
|
899 /*****************************************************************
|
yading@11
|
900 * All fields below this line are not part of the public API. They
|
yading@11
|
901 * may not be used outside of libavformat and can be changed and
|
yading@11
|
902 * removed at will.
|
yading@11
|
903 * New public fields should be added right above.
|
yading@11
|
904 *****************************************************************
|
yading@11
|
905 */
|
yading@11
|
906 int64_t start_time;
|
yading@11
|
907 int64_t end_time;
|
yading@11
|
908
|
yading@11
|
909 int64_t pts_wrap_reference; ///< reference dts for wrap detection
|
yading@11
|
910 int pts_wrap_behavior; ///< behavior on wrap detection
|
yading@11
|
911 } AVProgram;
|
yading@11
|
912
|
yading@11
|
913 #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
|
yading@11
|
914 (streams are added dynamically) */
|
yading@11
|
915
|
yading@11
|
916 typedef struct AVChapter {
|
yading@11
|
917 int id; ///< unique ID to identify the chapter
|
yading@11
|
918 AVRational time_base; ///< time base in which the start/end timestamps are specified
|
yading@11
|
919 int64_t start, end; ///< chapter start/end time in time_base units
|
yading@11
|
920 AVDictionary *metadata;
|
yading@11
|
921 } AVChapter;
|
yading@11
|
922
|
yading@11
|
923
|
yading@11
|
924 /**
|
yading@11
|
925 * The duration of a video can be estimated through various ways, and this enum can be used
|
yading@11
|
926 * to know how the duration was estimated.
|
yading@11
|
927 */
|
yading@11
|
928 enum AVDurationEstimationMethod {
|
yading@11
|
929 AVFMT_DURATION_FROM_PTS, ///< Duration accurately estimated from PTSes
|
yading@11
|
930 AVFMT_DURATION_FROM_STREAM, ///< Duration estimated from a stream with a known duration
|
yading@11
|
931 AVFMT_DURATION_FROM_BITRATE ///< Duration estimated from bitrate (less accurate)
|
yading@11
|
932 };
|
yading@11
|
933
|
yading@11
|
934 /**
|
yading@11
|
935 * Format I/O context.
|
yading@11
|
936 * New fields can be added to the end with minor version bumps.
|
yading@11
|
937 * Removal, reordering and changes to existing fields require a major
|
yading@11
|
938 * version bump.
|
yading@11
|
939 * sizeof(AVFormatContext) must not be used outside libav*, use
|
yading@11
|
940 * avformat_alloc_context() to create an AVFormatContext.
|
yading@11
|
941 */
|
yading@11
|
942 typedef struct AVFormatContext {
|
yading@11
|
943 /**
|
yading@11
|
944 * A class for logging and AVOptions. Set by avformat_alloc_context().
|
yading@11
|
945 * Exports (de)muxer private options if they exist.
|
yading@11
|
946 */
|
yading@11
|
947 const AVClass *av_class;
|
yading@11
|
948
|
yading@11
|
949 /**
|
yading@11
|
950 * Can only be iformat or oformat, not both at the same time.
|
yading@11
|
951 *
|
yading@11
|
952 * decoding: set by avformat_open_input().
|
yading@11
|
953 * encoding: set by the user.
|
yading@11
|
954 */
|
yading@11
|
955 struct AVInputFormat *iformat;
|
yading@11
|
956 struct AVOutputFormat *oformat;
|
yading@11
|
957
|
yading@11
|
958 /**
|
yading@11
|
959 * Format private data. This is an AVOptions-enabled struct
|
yading@11
|
960 * if and only if iformat/oformat.priv_class is not NULL.
|
yading@11
|
961 */
|
yading@11
|
962 void *priv_data;
|
yading@11
|
963
|
yading@11
|
964 /**
|
yading@11
|
965 * I/O context.
|
yading@11
|
966 *
|
yading@11
|
967 * decoding: either set by the user before avformat_open_input() (then
|
yading@11
|
968 * the user must close it manually) or set by avformat_open_input().
|
yading@11
|
969 * encoding: set by the user.
|
yading@11
|
970 *
|
yading@11
|
971 * Do NOT set this field if AVFMT_NOFILE flag is set in
|
yading@11
|
972 * iformat/oformat.flags. In such a case, the (de)muxer will handle
|
yading@11
|
973 * I/O in some other way and this field will be NULL.
|
yading@11
|
974 */
|
yading@11
|
975 AVIOContext *pb;
|
yading@11
|
976
|
yading@11
|
977 /* stream info */
|
yading@11
|
978 int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
|
yading@11
|
979
|
yading@11
|
980 /**
|
yading@11
|
981 * A list of all streams in the file. New streams are created with
|
yading@11
|
982 * avformat_new_stream().
|
yading@11
|
983 *
|
yading@11
|
984 * decoding: streams are created by libavformat in avformat_open_input().
|
yading@11
|
985 * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also
|
yading@11
|
986 * appear in av_read_frame().
|
yading@11
|
987 * encoding: streams are created by the user before avformat_write_header().
|
yading@11
|
988 */
|
yading@11
|
989 unsigned int nb_streams;
|
yading@11
|
990 AVStream **streams;
|
yading@11
|
991
|
yading@11
|
992 char filename[1024]; /**< input or output filename */
|
yading@11
|
993
|
yading@11
|
994 /**
|
yading@11
|
995 * Decoding: position of the first frame of the component, in
|
yading@11
|
996 * AV_TIME_BASE fractional seconds. NEVER set this value directly:
|
yading@11
|
997 * It is deduced from the AVStream values.
|
yading@11
|
998 */
|
yading@11
|
999 int64_t start_time;
|
yading@11
|
1000
|
yading@11
|
1001 /**
|
yading@11
|
1002 * Decoding: duration of the stream, in AV_TIME_BASE fractional
|
yading@11
|
1003 * seconds. Only set this value if you know none of the individual stream
|
yading@11
|
1004 * durations and also do not set any of them. This is deduced from the
|
yading@11
|
1005 * AVStream values if not set.
|
yading@11
|
1006 */
|
yading@11
|
1007 int64_t duration;
|
yading@11
|
1008
|
yading@11
|
1009 /**
|
yading@11
|
1010 * Decoding: total stream bitrate in bit/s, 0 if not
|
yading@11
|
1011 * available. Never set it directly if the file_size and the
|
yading@11
|
1012 * duration are known as FFmpeg can compute it automatically.
|
yading@11
|
1013 */
|
yading@11
|
1014 int bit_rate;
|
yading@11
|
1015
|
yading@11
|
1016 unsigned int packet_size;
|
yading@11
|
1017 int max_delay;
|
yading@11
|
1018
|
yading@11
|
1019 int flags;
|
yading@11
|
1020 #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
|
yading@11
|
1021 #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
|
yading@11
|
1022 #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
|
yading@11
|
1023 #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
|
yading@11
|
1024 #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
|
yading@11
|
1025 #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
|
yading@11
|
1026 #define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible
|
yading@11
|
1027 #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
|
yading@11
|
1028 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
|
yading@11
|
1029 #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload
|
yading@11
|
1030 #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
|
yading@11
|
1031 #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)
|
yading@11
|
1032 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.
|
yading@11
|
1033
|
yading@11
|
1034 /**
|
yading@11
|
1035 * decoding: size of data to probe; encoding: unused.
|
yading@11
|
1036 */
|
yading@11
|
1037 unsigned int probesize;
|
yading@11
|
1038
|
yading@11
|
1039 /**
|
yading@11
|
1040 * decoding: maximum time (in AV_TIME_BASE units) during which the input should
|
yading@11
|
1041 * be analyzed in avformat_find_stream_info().
|
yading@11
|
1042 */
|
yading@11
|
1043 int max_analyze_duration;
|
yading@11
|
1044
|
yading@11
|
1045 const uint8_t *key;
|
yading@11
|
1046 int keylen;
|
yading@11
|
1047
|
yading@11
|
1048 unsigned int nb_programs;
|
yading@11
|
1049 AVProgram **programs;
|
yading@11
|
1050
|
yading@11
|
1051 /**
|
yading@11
|
1052 * Forced video codec_id.
|
yading@11
|
1053 * Demuxing: Set by user.
|
yading@11
|
1054 */
|
yading@11
|
1055 enum AVCodecID video_codec_id;
|
yading@11
|
1056
|
yading@11
|
1057 /**
|
yading@11
|
1058 * Forced audio codec_id.
|
yading@11
|
1059 * Demuxing: Set by user.
|
yading@11
|
1060 */
|
yading@11
|
1061 enum AVCodecID audio_codec_id;
|
yading@11
|
1062
|
yading@11
|
1063 /**
|
yading@11
|
1064 * Forced subtitle codec_id.
|
yading@11
|
1065 * Demuxing: Set by user.
|
yading@11
|
1066 */
|
yading@11
|
1067 enum AVCodecID subtitle_codec_id;
|
yading@11
|
1068
|
yading@11
|
1069 /**
|
yading@11
|
1070 * Maximum amount of memory in bytes to use for the index of each stream.
|
yading@11
|
1071 * If the index exceeds this size, entries will be discarded as
|
yading@11
|
1072 * needed to maintain a smaller size. This can lead to slower or less
|
yading@11
|
1073 * accurate seeking (depends on demuxer).
|
yading@11
|
1074 * Demuxers for which a full in-memory index is mandatory will ignore
|
yading@11
|
1075 * this.
|
yading@11
|
1076 * muxing : unused
|
yading@11
|
1077 * demuxing: set by user
|
yading@11
|
1078 */
|
yading@11
|
1079 unsigned int max_index_size;
|
yading@11
|
1080
|
yading@11
|
1081 /**
|
yading@11
|
1082 * Maximum amount of memory in bytes to use for buffering frames
|
yading@11
|
1083 * obtained from realtime capture devices.
|
yading@11
|
1084 */
|
yading@11
|
1085 unsigned int max_picture_buffer;
|
yading@11
|
1086
|
yading@11
|
1087 unsigned int nb_chapters;
|
yading@11
|
1088 AVChapter **chapters;
|
yading@11
|
1089
|
yading@11
|
1090 AVDictionary *metadata;
|
yading@11
|
1091
|
yading@11
|
1092 /**
|
yading@11
|
1093 * Start time of the stream in real world time, in microseconds
|
yading@11
|
1094 * since the unix epoch (00:00 1st January 1970). That is, pts=0
|
yading@11
|
1095 * in the stream was captured at this real world time.
|
yading@11
|
1096 * - encoding: Set by user.
|
yading@11
|
1097 * - decoding: Unused.
|
yading@11
|
1098 */
|
yading@11
|
1099 int64_t start_time_realtime;
|
yading@11
|
1100
|
yading@11
|
1101 /**
|
yading@11
|
1102 * decoding: number of frames used to probe fps
|
yading@11
|
1103 */
|
yading@11
|
1104 int fps_probe_size;
|
yading@11
|
1105
|
yading@11
|
1106 /**
|
yading@11
|
1107 * Error recognition; higher values will detect more errors but may
|
yading@11
|
1108 * misdetect some more or less valid parts as errors.
|
yading@11
|
1109 * - encoding: unused
|
yading@11
|
1110 * - decoding: Set by user.
|
yading@11
|
1111 */
|
yading@11
|
1112 int error_recognition;
|
yading@11
|
1113
|
yading@11
|
1114 /**
|
yading@11
|
1115 * Custom interrupt callbacks for the I/O layer.
|
yading@11
|
1116 *
|
yading@11
|
1117 * decoding: set by the user before avformat_open_input().
|
yading@11
|
1118 * encoding: set by the user before avformat_write_header()
|
yading@11
|
1119 * (mainly useful for AVFMT_NOFILE formats). The callback
|
yading@11
|
1120 * should also be passed to avio_open2() if it's used to
|
yading@11
|
1121 * open the file.
|
yading@11
|
1122 */
|
yading@11
|
1123 AVIOInterruptCB interrupt_callback;
|
yading@11
|
1124
|
yading@11
|
1125 /**
|
yading@11
|
1126 * Flags to enable debugging.
|
yading@11
|
1127 */
|
yading@11
|
1128 int debug;
|
yading@11
|
1129 #define FF_FDEBUG_TS 0x0001
|
yading@11
|
1130
|
yading@11
|
1131 /**
|
yading@11
|
1132 * Transport stream id.
|
yading@11
|
1133 * This will be moved into demuxer private options. Thus no API/ABI compatibility
|
yading@11
|
1134 */
|
yading@11
|
1135 int ts_id;
|
yading@11
|
1136
|
yading@11
|
1137 /**
|
yading@11
|
1138 * Audio preload in microseconds.
|
yading@11
|
1139 * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
|
yading@11
|
1140 * - encoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1141 * - decoding: unused
|
yading@11
|
1142 */
|
yading@11
|
1143 int audio_preload;
|
yading@11
|
1144
|
yading@11
|
1145 /**
|
yading@11
|
1146 * Max chunk time in microseconds.
|
yading@11
|
1147 * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
|
yading@11
|
1148 * - encoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1149 * - decoding: unused
|
yading@11
|
1150 */
|
yading@11
|
1151 int max_chunk_duration;
|
yading@11
|
1152
|
yading@11
|
1153 /**
|
yading@11
|
1154 * Max chunk size in bytes
|
yading@11
|
1155 * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
|
yading@11
|
1156 * - encoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1157 * - decoding: unused
|
yading@11
|
1158 */
|
yading@11
|
1159 int max_chunk_size;
|
yading@11
|
1160
|
yading@11
|
1161 /**
|
yading@11
|
1162 * forces the use of wallclock timestamps as pts/dts of packets
|
yading@11
|
1163 * This has undefined results in the presence of B frames.
|
yading@11
|
1164 * - encoding: unused
|
yading@11
|
1165 * - decoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1166 */
|
yading@11
|
1167 int use_wallclock_as_timestamps;
|
yading@11
|
1168
|
yading@11
|
1169 /**
|
yading@11
|
1170 * Avoid negative timestamps during muxing.
|
yading@11
|
1171 * 0 -> allow negative timestamps
|
yading@11
|
1172 * 1 -> avoid negative timestamps
|
yading@11
|
1173 * -1 -> choose automatically (default)
|
yading@11
|
1174 * Note, this only works when interleave_packet_per_dts is in use.
|
yading@11
|
1175 * - encoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1176 * - decoding: unused
|
yading@11
|
1177 */
|
yading@11
|
1178 int avoid_negative_ts;
|
yading@11
|
1179
|
yading@11
|
1180 /**
|
yading@11
|
1181 * avio flags, used to force AVIO_FLAG_DIRECT.
|
yading@11
|
1182 * - encoding: unused
|
yading@11
|
1183 * - decoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1184 */
|
yading@11
|
1185 int avio_flags;
|
yading@11
|
1186
|
yading@11
|
1187 /**
|
yading@11
|
1188 * The duration field can be estimated through various ways, and this field can be used
|
yading@11
|
1189 * to know how the duration was estimated.
|
yading@11
|
1190 * - encoding: unused
|
yading@11
|
1191 * - decoding: Read by user via AVOptions (NO direct access)
|
yading@11
|
1192 */
|
yading@11
|
1193 enum AVDurationEstimationMethod duration_estimation_method;
|
yading@11
|
1194
|
yading@11
|
1195 /**
|
yading@11
|
1196 * Skip initial bytes when opening stream
|
yading@11
|
1197 * - encoding: unused
|
yading@11
|
1198 * - decoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1199 */
|
yading@11
|
1200 unsigned int skip_initial_bytes;
|
yading@11
|
1201
|
yading@11
|
1202 /**
|
yading@11
|
1203 * Correct single timestamp overflows
|
yading@11
|
1204 * - encoding: unused
|
yading@11
|
1205 * - decoding: Set by user via AVOPtions (NO direct access)
|
yading@11
|
1206 */
|
yading@11
|
1207 unsigned int correct_ts_overflow;
|
yading@11
|
1208
|
yading@11
|
1209 /**
|
yading@11
|
1210 * Force seeking to any (also non key) frames.
|
yading@11
|
1211 * - encoding: unused
|
yading@11
|
1212 * - decoding: Set by user via AVOPtions (NO direct access)
|
yading@11
|
1213 */
|
yading@11
|
1214 int seek2any;
|
yading@11
|
1215
|
yading@11
|
1216 /**
|
yading@11
|
1217 * Flush the I/O context after each packet.
|
yading@11
|
1218 * - encoding: Set by user via AVOptions (NO direct access)
|
yading@11
|
1219 * - decoding: unused
|
yading@11
|
1220 */
|
yading@11
|
1221 int flush_packets;
|
yading@11
|
1222
|
yading@11
|
1223 /*****************************************************************
|
yading@11
|
1224 * All fields below this line are not part of the public API. They
|
yading@11
|
1225 * may not be used outside of libavformat and can be changed and
|
yading@11
|
1226 * removed at will.
|
yading@11
|
1227 * New public fields should be added right above.
|
yading@11
|
1228 *****************************************************************
|
yading@11
|
1229 */
|
yading@11
|
1230
|
yading@11
|
1231 /**
|
yading@11
|
1232 * This buffer is only needed when packets were already buffered but
|
yading@11
|
1233 * not decoded, for example to get the codec parameters in MPEG
|
yading@11
|
1234 * streams.
|
yading@11
|
1235 */
|
yading@11
|
1236 struct AVPacketList *packet_buffer;
|
yading@11
|
1237 struct AVPacketList *packet_buffer_end;
|
yading@11
|
1238
|
yading@11
|
1239 /* av_seek_frame() support */
|
yading@11
|
1240 int64_t data_offset; /**< offset of the first packet */
|
yading@11
|
1241
|
yading@11
|
1242 /**
|
yading@11
|
1243 * Raw packets from the demuxer, prior to parsing and decoding.
|
yading@11
|
1244 * This buffer is used for buffering packets until the codec can
|
yading@11
|
1245 * be identified, as parsing cannot be done without knowing the
|
yading@11
|
1246 * codec.
|
yading@11
|
1247 */
|
yading@11
|
1248 struct AVPacketList *raw_packet_buffer;
|
yading@11
|
1249 struct AVPacketList *raw_packet_buffer_end;
|
yading@11
|
1250 /**
|
yading@11
|
1251 * Packets split by the parser get queued here.
|
yading@11
|
1252 */
|
yading@11
|
1253 struct AVPacketList *parse_queue;
|
yading@11
|
1254 struct AVPacketList *parse_queue_end;
|
yading@11
|
1255 /**
|
yading@11
|
1256 * Remaining size available for raw_packet_buffer, in bytes.
|
yading@11
|
1257 */
|
yading@11
|
1258 #define RAW_PACKET_BUFFER_SIZE 2500000
|
yading@11
|
1259 int raw_packet_buffer_remaining_size;
|
yading@11
|
1260
|
yading@11
|
1261 /**
|
yading@11
|
1262 * IO repositioned flag.
|
yading@11
|
1263 * This is set by avformat when the underlaying IO context read pointer
|
yading@11
|
1264 * is repositioned, for example when doing byte based seeking.
|
yading@11
|
1265 * Demuxers can use the flag to detect such changes.
|
yading@11
|
1266 */
|
yading@11
|
1267 int io_repositioned;
|
yading@11
|
1268 } AVFormatContext;
|
yading@11
|
1269
|
yading@11
|
1270 /**
|
yading@11
|
1271 * Returns the method used to set ctx->duration.
|
yading@11
|
1272 *
|
yading@11
|
1273 * @return AVFMT_DURATION_FROM_PTS, AVFMT_DURATION_FROM_STREAM, or AVFMT_DURATION_FROM_BITRATE.
|
yading@11
|
1274 */
|
yading@11
|
1275 enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx);
|
yading@11
|
1276
|
yading@11
|
1277 typedef struct AVPacketList {
|
yading@11
|
1278 AVPacket pkt;
|
yading@11
|
1279 struct AVPacketList *next;
|
yading@11
|
1280 } AVPacketList;
|
yading@11
|
1281
|
yading@11
|
1282
|
yading@11
|
1283 /**
|
yading@11
|
1284 * @defgroup lavf_core Core functions
|
yading@11
|
1285 * @ingroup libavf
|
yading@11
|
1286 *
|
yading@11
|
1287 * Functions for querying libavformat capabilities, allocating core structures,
|
yading@11
|
1288 * etc.
|
yading@11
|
1289 * @{
|
yading@11
|
1290 */
|
yading@11
|
1291
|
yading@11
|
1292 /**
|
yading@11
|
1293 * Return the LIBAVFORMAT_VERSION_INT constant.
|
yading@11
|
1294 */
|
yading@11
|
1295 unsigned avformat_version(void);
|
yading@11
|
1296
|
yading@11
|
1297 /**
|
yading@11
|
1298 * Return the libavformat build-time configuration.
|
yading@11
|
1299 */
|
yading@11
|
1300 const char *avformat_configuration(void);
|
yading@11
|
1301
|
yading@11
|
1302 /**
|
yading@11
|
1303 * Return the libavformat license.
|
yading@11
|
1304 */
|
yading@11
|
1305 const char *avformat_license(void);
|
yading@11
|
1306
|
yading@11
|
1307 /**
|
yading@11
|
1308 * Initialize libavformat and register all the muxers, demuxers and
|
yading@11
|
1309 * protocols. If you do not call this function, then you can select
|
yading@11
|
1310 * exactly which formats you want to support.
|
yading@11
|
1311 *
|
yading@11
|
1312 * @see av_register_input_format()
|
yading@11
|
1313 * @see av_register_output_format()
|
yading@11
|
1314 */
|
yading@11
|
1315 void av_register_all(void);
|
yading@11
|
1316
|
yading@11
|
1317 void av_register_input_format(AVInputFormat *format);
|
yading@11
|
1318 void av_register_output_format(AVOutputFormat *format);
|
yading@11
|
1319
|
yading@11
|
1320 /**
|
yading@11
|
1321 * Do global initialization of network components. This is optional,
|
yading@11
|
1322 * but recommended, since it avoids the overhead of implicitly
|
yading@11
|
1323 * doing the setup for each session.
|
yading@11
|
1324 *
|
yading@11
|
1325 * Calling this function will become mandatory if using network
|
yading@11
|
1326 * protocols at some major version bump.
|
yading@11
|
1327 */
|
yading@11
|
1328 int avformat_network_init(void);
|
yading@11
|
1329
|
yading@11
|
1330 /**
|
yading@11
|
1331 * Undo the initialization done by avformat_network_init.
|
yading@11
|
1332 */
|
yading@11
|
1333 int avformat_network_deinit(void);
|
yading@11
|
1334
|
yading@11
|
1335 /**
|
yading@11
|
1336 * If f is NULL, returns the first registered input format,
|
yading@11
|
1337 * if f is non-NULL, returns the next registered input format after f
|
yading@11
|
1338 * or NULL if f is the last one.
|
yading@11
|
1339 */
|
yading@11
|
1340 AVInputFormat *av_iformat_next(AVInputFormat *f);
|
yading@11
|
1341
|
yading@11
|
1342 /**
|
yading@11
|
1343 * If f is NULL, returns the first registered output format,
|
yading@11
|
1344 * if f is non-NULL, returns the next registered output format after f
|
yading@11
|
1345 * or NULL if f is the last one.
|
yading@11
|
1346 */
|
yading@11
|
1347 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
|
yading@11
|
1348
|
yading@11
|
1349 /**
|
yading@11
|
1350 * Allocate an AVFormatContext.
|
yading@11
|
1351 * avformat_free_context() can be used to free the context and everything
|
yading@11
|
1352 * allocated by the framework within it.
|
yading@11
|
1353 */
|
yading@11
|
1354 AVFormatContext *avformat_alloc_context(void);
|
yading@11
|
1355
|
yading@11
|
1356 /**
|
yading@11
|
1357 * Free an AVFormatContext and all its streams.
|
yading@11
|
1358 * @param s context to free
|
yading@11
|
1359 */
|
yading@11
|
1360 void avformat_free_context(AVFormatContext *s);
|
yading@11
|
1361
|
yading@11
|
1362 /**
|
yading@11
|
1363 * Get the AVClass for AVFormatContext. It can be used in combination with
|
yading@11
|
1364 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
|
yading@11
|
1365 *
|
yading@11
|
1366 * @see av_opt_find().
|
yading@11
|
1367 */
|
yading@11
|
1368 const AVClass *avformat_get_class(void);
|
yading@11
|
1369
|
yading@11
|
1370 /**
|
yading@11
|
1371 * Add a new stream to a media file.
|
yading@11
|
1372 *
|
yading@11
|
1373 * When demuxing, it is called by the demuxer in read_header(). If the
|
yading@11
|
1374 * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also
|
yading@11
|
1375 * be called in read_packet().
|
yading@11
|
1376 *
|
yading@11
|
1377 * When muxing, should be called by the user before avformat_write_header().
|
yading@11
|
1378 *
|
yading@11
|
1379 * @param c If non-NULL, the AVCodecContext corresponding to the new stream
|
yading@11
|
1380 * will be initialized to use this codec. This is needed for e.g. codec-specific
|
yading@11
|
1381 * defaults to be set, so codec should be provided if it is known.
|
yading@11
|
1382 *
|
yading@11
|
1383 * @return newly created stream or NULL on error.
|
yading@11
|
1384 */
|
yading@11
|
1385 AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
|
yading@11
|
1386
|
yading@11
|
1387 AVProgram *av_new_program(AVFormatContext *s, int id);
|
yading@11
|
1388
|
yading@11
|
1389 /**
|
yading@11
|
1390 * @}
|
yading@11
|
1391 */
|
yading@11
|
1392
|
yading@11
|
1393
|
yading@11
|
1394 #if FF_API_PKT_DUMP
|
yading@11
|
1395 attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
|
yading@11
|
1396 attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
|
yading@11
|
1397 int dump_payload);
|
yading@11
|
1398 #endif
|
yading@11
|
1399
|
yading@11
|
1400 #if FF_API_ALLOC_OUTPUT_CONTEXT
|
yading@11
|
1401 /**
|
yading@11
|
1402 * @deprecated deprecated in favor of avformat_alloc_output_context2()
|
yading@11
|
1403 */
|
yading@11
|
1404 attribute_deprecated
|
yading@11
|
1405 AVFormatContext *avformat_alloc_output_context(const char *format,
|
yading@11
|
1406 AVOutputFormat *oformat,
|
yading@11
|
1407 const char *filename);
|
yading@11
|
1408 #endif
|
yading@11
|
1409
|
yading@11
|
1410 /**
|
yading@11
|
1411 * Allocate an AVFormatContext for an output format.
|
yading@11
|
1412 * avformat_free_context() can be used to free the context and
|
yading@11
|
1413 * everything allocated by the framework within it.
|
yading@11
|
1414 *
|
yading@11
|
1415 * @param *ctx is set to the created format context, or to NULL in
|
yading@11
|
1416 * case of failure
|
yading@11
|
1417 * @param oformat format to use for allocating the context, if NULL
|
yading@11
|
1418 * format_name and filename are used instead
|
yading@11
|
1419 * @param format_name the name of output format to use for allocating the
|
yading@11
|
1420 * context, if NULL filename is used instead
|
yading@11
|
1421 * @param filename the name of the filename to use for allocating the
|
yading@11
|
1422 * context, may be NULL
|
yading@11
|
1423 * @return >= 0 in case of success, a negative AVERROR code in case of
|
yading@11
|
1424 * failure
|
yading@11
|
1425 */
|
yading@11
|
1426 int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat,
|
yading@11
|
1427 const char *format_name, const char *filename);
|
yading@11
|
1428
|
yading@11
|
1429 /**
|
yading@11
|
1430 * @addtogroup lavf_decoding
|
yading@11
|
1431 * @{
|
yading@11
|
1432 */
|
yading@11
|
1433
|
yading@11
|
1434 /**
|
yading@11
|
1435 * Find AVInputFormat based on the short name of the input format.
|
yading@11
|
1436 */
|
yading@11
|
1437 AVInputFormat *av_find_input_format(const char *short_name);
|
yading@11
|
1438
|
yading@11
|
1439 /**
|
yading@11
|
1440 * Guess the file format.
|
yading@11
|
1441 *
|
yading@11
|
1442 * @param is_opened Whether the file is already opened; determines whether
|
yading@11
|
1443 * demuxers with or without AVFMT_NOFILE are probed.
|
yading@11
|
1444 */
|
yading@11
|
1445 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
|
yading@11
|
1446
|
yading@11
|
1447 /**
|
yading@11
|
1448 * Guess the file format.
|
yading@11
|
1449 *
|
yading@11
|
1450 * @param is_opened Whether the file is already opened; determines whether
|
yading@11
|
1451 * demuxers with or without AVFMT_NOFILE are probed.
|
yading@11
|
1452 * @param score_max A probe score larger that this is required to accept a
|
yading@11
|
1453 * detection, the variable is set to the actual detection
|
yading@11
|
1454 * score afterwards.
|
yading@11
|
1455 * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended
|
yading@11
|
1456 * to retry with a larger probe buffer.
|
yading@11
|
1457 */
|
yading@11
|
1458 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
|
yading@11
|
1459
|
yading@11
|
1460 /**
|
yading@11
|
1461 * Guess the file format.
|
yading@11
|
1462 *
|
yading@11
|
1463 * @param is_opened Whether the file is already opened; determines whether
|
yading@11
|
1464 * demuxers with or without AVFMT_NOFILE are probed.
|
yading@11
|
1465 * @param score_ret The score of the best detection.
|
yading@11
|
1466 */
|
yading@11
|
1467 AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret);
|
yading@11
|
1468
|
yading@11
|
1469 /**
|
yading@11
|
1470 * Probe a bytestream to determine the input format. Each time a probe returns
|
yading@11
|
1471 * with a score that is too low, the probe buffer size is increased and another
|
yading@11
|
1472 * attempt is made. When the maximum probe size is reached, the input format
|
yading@11
|
1473 * with the highest score is returned.
|
yading@11
|
1474 *
|
yading@11
|
1475 * @param pb the bytestream to probe
|
yading@11
|
1476 * @param fmt the input format is put here
|
yading@11
|
1477 * @param filename the filename of the stream
|
yading@11
|
1478 * @param logctx the log context
|
yading@11
|
1479 * @param offset the offset within the bytestream to probe from
|
yading@11
|
1480 * @param max_probe_size the maximum probe buffer size (zero for default)
|
yading@11
|
1481 * @return 0 in case of success, a negative value corresponding to an
|
yading@11
|
1482 * AVERROR code otherwise
|
yading@11
|
1483 */
|
yading@11
|
1484 int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
|
yading@11
|
1485 const char *filename, void *logctx,
|
yading@11
|
1486 unsigned int offset, unsigned int max_probe_size);
|
yading@11
|
1487
|
yading@11
|
1488 /**
|
yading@11
|
1489 * Open an input stream and read the header. The codecs are not opened.
|
yading@11
|
1490 * The stream must be closed with av_close_input_file().
|
yading@11
|
1491 *
|
yading@11
|
1492 * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
|
yading@11
|
1493 * May be a pointer to NULL, in which case an AVFormatContext is allocated by this
|
yading@11
|
1494 * function and written into ps.
|
yading@11
|
1495 * Note that a user-supplied AVFormatContext will be freed on failure.
|
yading@11
|
1496 * @param filename Name of the stream to open.
|
yading@11
|
1497 * @param fmt If non-NULL, this parameter forces a specific input format.
|
yading@11
|
1498 * Otherwise the format is autodetected.
|
yading@11
|
1499 * @param options A dictionary filled with AVFormatContext and demuxer-private options.
|
yading@11
|
1500 * On return this parameter will be destroyed and replaced with a dict containing
|
yading@11
|
1501 * options that were not found. May be NULL.
|
yading@11
|
1502 *
|
yading@11
|
1503 * @return 0 on success, a negative AVERROR on failure.
|
yading@11
|
1504 *
|
yading@11
|
1505 * @note If you want to use custom IO, preallocate the format context and set its pb field.
|
yading@11
|
1506 */
|
yading@11
|
1507 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
|
yading@11
|
1508
|
yading@11
|
1509 attribute_deprecated
|
yading@11
|
1510 int av_demuxer_open(AVFormatContext *ic);
|
yading@11
|
1511
|
yading@11
|
1512 #if FF_API_FORMAT_PARAMETERS
|
yading@11
|
1513 /**
|
yading@11
|
1514 * Read packets of a media file to get stream information. This
|
yading@11
|
1515 * is useful for file formats with no headers such as MPEG. This
|
yading@11
|
1516 * function also computes the real framerate in case of MPEG-2 repeat
|
yading@11
|
1517 * frame mode.
|
yading@11
|
1518 * The logical file position is not changed by this function;
|
yading@11
|
1519 * examined packets may be buffered for later processing.
|
yading@11
|
1520 *
|
yading@11
|
1521 * @param ic media file handle
|
yading@11
|
1522 * @return >=0 if OK, AVERROR_xxx on error
|
yading@11
|
1523 * @todo Let the user decide somehow what information is needed so that
|
yading@11
|
1524 * we do not waste time getting stuff the user does not need.
|
yading@11
|
1525 *
|
yading@11
|
1526 * @deprecated use avformat_find_stream_info.
|
yading@11
|
1527 */
|
yading@11
|
1528 attribute_deprecated
|
yading@11
|
1529 int av_find_stream_info(AVFormatContext *ic);
|
yading@11
|
1530 #endif
|
yading@11
|
1531
|
yading@11
|
1532 /**
|
yading@11
|
1533 * Read packets of a media file to get stream information. This
|
yading@11
|
1534 * is useful for file formats with no headers such as MPEG. This
|
yading@11
|
1535 * function also computes the real framerate in case of MPEG-2 repeat
|
yading@11
|
1536 * frame mode.
|
yading@11
|
1537 * The logical file position is not changed by this function;
|
yading@11
|
1538 * examined packets may be buffered for later processing.
|
yading@11
|
1539 *
|
yading@11
|
1540 * @param ic media file handle
|
yading@11
|
1541 * @param options If non-NULL, an ic.nb_streams long array of pointers to
|
yading@11
|
1542 * dictionaries, where i-th member contains options for
|
yading@11
|
1543 * codec corresponding to i-th stream.
|
yading@11
|
1544 * On return each dictionary will be filled with options that were not found.
|
yading@11
|
1545 * @return >=0 if OK, AVERROR_xxx on error
|
yading@11
|
1546 *
|
yading@11
|
1547 * @note this function isn't guaranteed to open all the codecs, so
|
yading@11
|
1548 * options being non-empty at return is a perfectly normal behavior.
|
yading@11
|
1549 *
|
yading@11
|
1550 * @todo Let the user decide somehow what information is needed so that
|
yading@11
|
1551 * we do not waste time getting stuff the user does not need.
|
yading@11
|
1552 */
|
yading@11
|
1553 int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
|
yading@11
|
1554
|
yading@11
|
1555 /**
|
yading@11
|
1556 * Find the programs which belong to a given stream.
|
yading@11
|
1557 *
|
yading@11
|
1558 * @param ic media file handle
|
yading@11
|
1559 * @param last the last found program, the search will start after this
|
yading@11
|
1560 * program, or from the beginning if it is NULL
|
yading@11
|
1561 * @param s stream index
|
yading@11
|
1562 * @return the next program which belongs to s, NULL if no program is found or
|
yading@11
|
1563 * the last program is not among the programs of ic.
|
yading@11
|
1564 */
|
yading@11
|
1565 AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s);
|
yading@11
|
1566
|
yading@11
|
1567 /**
|
yading@11
|
1568 * Find the "best" stream in the file.
|
yading@11
|
1569 * The best stream is determined according to various heuristics as the most
|
yading@11
|
1570 * likely to be what the user expects.
|
yading@11
|
1571 * If the decoder parameter is non-NULL, av_find_best_stream will find the
|
yading@11
|
1572 * default decoder for the stream's codec; streams for which no decoder can
|
yading@11
|
1573 * be found are ignored.
|
yading@11
|
1574 *
|
yading@11
|
1575 * @param ic media file handle
|
yading@11
|
1576 * @param type stream type: video, audio, subtitles, etc.
|
yading@11
|
1577 * @param wanted_stream_nb user-requested stream number,
|
yading@11
|
1578 * or -1 for automatic selection
|
yading@11
|
1579 * @param related_stream try to find a stream related (eg. in the same
|
yading@11
|
1580 * program) to this one, or -1 if none
|
yading@11
|
1581 * @param decoder_ret if non-NULL, returns the decoder for the
|
yading@11
|
1582 * selected stream
|
yading@11
|
1583 * @param flags flags; none are currently defined
|
yading@11
|
1584 * @return the non-negative stream number in case of success,
|
yading@11
|
1585 * AVERROR_STREAM_NOT_FOUND if no stream with the requested type
|
yading@11
|
1586 * could be found,
|
yading@11
|
1587 * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
|
yading@11
|
1588 * @note If av_find_best_stream returns successfully and decoder_ret is not
|
yading@11
|
1589 * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
|
yading@11
|
1590 */
|
yading@11
|
1591 int av_find_best_stream(AVFormatContext *ic,
|
yading@11
|
1592 enum AVMediaType type,
|
yading@11
|
1593 int wanted_stream_nb,
|
yading@11
|
1594 int related_stream,
|
yading@11
|
1595 AVCodec **decoder_ret,
|
yading@11
|
1596 int flags);
|
yading@11
|
1597
|
yading@11
|
1598 #if FF_API_READ_PACKET
|
yading@11
|
1599 /**
|
yading@11
|
1600 * @deprecated use AVFMT_FLAG_NOFILLIN | AVFMT_FLAG_NOPARSE to read raw
|
yading@11
|
1601 * unprocessed packets
|
yading@11
|
1602 *
|
yading@11
|
1603 * Read a transport packet from a media file.
|
yading@11
|
1604 *
|
yading@11
|
1605 * This function is obsolete and should never be used.
|
yading@11
|
1606 * Use av_read_frame() instead.
|
yading@11
|
1607 *
|
yading@11
|
1608 * @param s media file handle
|
yading@11
|
1609 * @param pkt is filled
|
yading@11
|
1610 * @return 0 if OK, AVERROR_xxx on error
|
yading@11
|
1611 */
|
yading@11
|
1612 attribute_deprecated
|
yading@11
|
1613 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
|
yading@11
|
1614 #endif
|
yading@11
|
1615
|
yading@11
|
1616 /**
|
yading@11
|
1617 * Return the next frame of a stream.
|
yading@11
|
1618 * This function returns what is stored in the file, and does not validate
|
yading@11
|
1619 * that what is there are valid frames for the decoder. It will split what is
|
yading@11
|
1620 * stored in the file into frames and return one for each call. It will not
|
yading@11
|
1621 * omit invalid data between valid frames so as to give the decoder the maximum
|
yading@11
|
1622 * information possible for decoding.
|
yading@11
|
1623 *
|
yading@11
|
1624 * If pkt->buf is NULL, then the packet is valid until the next
|
yading@11
|
1625 * av_read_frame() or until av_close_input_file(). Otherwise the packet is valid
|
yading@11
|
1626 * indefinitely. In both cases the packet must be freed with
|
yading@11
|
1627 * av_free_packet when it is no longer needed. For video, the packet contains
|
yading@11
|
1628 * exactly one frame. For audio, it contains an integer number of frames if each
|
yading@11
|
1629 * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames
|
yading@11
|
1630 * have a variable size (e.g. MPEG audio), then it contains one frame.
|
yading@11
|
1631 *
|
yading@11
|
1632 * pkt->pts, pkt->dts and pkt->duration are always set to correct
|
yading@11
|
1633 * values in AVStream.time_base units (and guessed if the format cannot
|
yading@11
|
1634 * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
|
yading@11
|
1635 * has B-frames, so it is better to rely on pkt->dts if you do not
|
yading@11
|
1636 * decompress the payload.
|
yading@11
|
1637 *
|
yading@11
|
1638 * @return 0 if OK, < 0 on error or end of file
|
yading@11
|
1639 */
|
yading@11
|
1640 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
|
yading@11
|
1641
|
yading@11
|
1642 /**
|
yading@11
|
1643 * Seek to the keyframe at timestamp.
|
yading@11
|
1644 * 'timestamp' in 'stream_index'.
|
yading@11
|
1645 * @param stream_index If stream_index is (-1), a default
|
yading@11
|
1646 * stream is selected, and timestamp is automatically converted
|
yading@11
|
1647 * from AV_TIME_BASE units to the stream specific time_base.
|
yading@11
|
1648 * @param timestamp Timestamp in AVStream.time_base units
|
yading@11
|
1649 * or, if no stream is specified, in AV_TIME_BASE units.
|
yading@11
|
1650 * @param flags flags which select direction and seeking mode
|
yading@11
|
1651 * @return >= 0 on success
|
yading@11
|
1652 */
|
yading@11
|
1653 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
|
yading@11
|
1654 int flags);
|
yading@11
|
1655
|
yading@11
|
1656 /**
|
yading@11
|
1657 * Seek to timestamp ts.
|
yading@11
|
1658 * Seeking will be done so that the point from which all active streams
|
yading@11
|
1659 * can be presented successfully will be closest to ts and within min/max_ts.
|
yading@11
|
1660 * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
|
yading@11
|
1661 *
|
yading@11
|
1662 * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
|
yading@11
|
1663 * are the file position (this may not be supported by all demuxers).
|
yading@11
|
1664 * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
|
yading@11
|
1665 * in the stream with stream_index (this may not be supported by all demuxers).
|
yading@11
|
1666 * Otherwise all timestamps are in units of the stream selected by stream_index
|
yading@11
|
1667 * or if stream_index is -1, in AV_TIME_BASE units.
|
yading@11
|
1668 * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
|
yading@11
|
1669 * keyframes (this may not be supported by all demuxers).
|
yading@11
|
1670 *
|
yading@11
|
1671 * @param stream_index index of the stream which is used as time base reference
|
yading@11
|
1672 * @param min_ts smallest acceptable timestamp
|
yading@11
|
1673 * @param ts target timestamp
|
yading@11
|
1674 * @param max_ts largest acceptable timestamp
|
yading@11
|
1675 * @param flags flags
|
yading@11
|
1676 * @return >=0 on success, error code otherwise
|
yading@11
|
1677 *
|
yading@11
|
1678 * @note This is part of the new seek API which is still under construction.
|
yading@11
|
1679 * Thus do not use this yet. It may change at any time, do not expect
|
yading@11
|
1680 * ABI compatibility yet!
|
yading@11
|
1681 */
|
yading@11
|
1682 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
|
yading@11
|
1683
|
yading@11
|
1684 /**
|
yading@11
|
1685 * Start playing a network-based stream (e.g. RTSP stream) at the
|
yading@11
|
1686 * current position.
|
yading@11
|
1687 */
|
yading@11
|
1688 int av_read_play(AVFormatContext *s);
|
yading@11
|
1689
|
yading@11
|
1690 /**
|
yading@11
|
1691 * Pause a network-based stream (e.g. RTSP stream).
|
yading@11
|
1692 *
|
yading@11
|
1693 * Use av_read_play() to resume it.
|
yading@11
|
1694 */
|
yading@11
|
1695 int av_read_pause(AVFormatContext *s);
|
yading@11
|
1696
|
yading@11
|
1697 #if FF_API_CLOSE_INPUT_FILE
|
yading@11
|
1698 /**
|
yading@11
|
1699 * @deprecated use avformat_close_input()
|
yading@11
|
1700 * Close a media file (but not its codecs).
|
yading@11
|
1701 *
|
yading@11
|
1702 * @param s media file handle
|
yading@11
|
1703 */
|
yading@11
|
1704 attribute_deprecated
|
yading@11
|
1705 void av_close_input_file(AVFormatContext *s);
|
yading@11
|
1706 #endif
|
yading@11
|
1707
|
yading@11
|
1708 /**
|
yading@11
|
1709 * Close an opened input AVFormatContext. Free it and all its contents
|
yading@11
|
1710 * and set *s to NULL.
|
yading@11
|
1711 */
|
yading@11
|
1712 void avformat_close_input(AVFormatContext **s);
|
yading@11
|
1713 /**
|
yading@11
|
1714 * @}
|
yading@11
|
1715 */
|
yading@11
|
1716
|
yading@11
|
1717 #if FF_API_NEW_STREAM
|
yading@11
|
1718 /**
|
yading@11
|
1719 * Add a new stream to a media file.
|
yading@11
|
1720 *
|
yading@11
|
1721 * Can only be called in the read_header() function. If the flag
|
yading@11
|
1722 * AVFMTCTX_NOHEADER is in the format context, then new streams
|
yading@11
|
1723 * can be added in read_packet too.
|
yading@11
|
1724 *
|
yading@11
|
1725 * @param s media file handle
|
yading@11
|
1726 * @param id file-format-dependent stream ID
|
yading@11
|
1727 */
|
yading@11
|
1728 attribute_deprecated
|
yading@11
|
1729 AVStream *av_new_stream(AVFormatContext *s, int id);
|
yading@11
|
1730 #endif
|
yading@11
|
1731
|
yading@11
|
1732 #if FF_API_SET_PTS_INFO
|
yading@11
|
1733 /**
|
yading@11
|
1734 * @deprecated this function is not supposed to be called outside of lavf
|
yading@11
|
1735 */
|
yading@11
|
1736 attribute_deprecated
|
yading@11
|
1737 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
|
yading@11
|
1738 unsigned int pts_num, unsigned int pts_den);
|
yading@11
|
1739 #endif
|
yading@11
|
1740
|
yading@11
|
1741 #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
|
yading@11
|
1742 #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
|
yading@11
|
1743 #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes
|
yading@11
|
1744 #define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number
|
yading@11
|
1745
|
yading@11
|
1746 /**
|
yading@11
|
1747 * @addtogroup lavf_encoding
|
yading@11
|
1748 * @{
|
yading@11
|
1749 */
|
yading@11
|
1750 /**
|
yading@11
|
1751 * Allocate the stream private data and write the stream header to
|
yading@11
|
1752 * an output media file.
|
yading@11
|
1753 *
|
yading@11
|
1754 * @param s Media file handle, must be allocated with avformat_alloc_context().
|
yading@11
|
1755 * Its oformat field must be set to the desired output format;
|
yading@11
|
1756 * Its pb field must be set to an already openened AVIOContext.
|
yading@11
|
1757 * @param options An AVDictionary filled with AVFormatContext and muxer-private options.
|
yading@11
|
1758 * On return this parameter will be destroyed and replaced with a dict containing
|
yading@11
|
1759 * options that were not found. May be NULL.
|
yading@11
|
1760 *
|
yading@11
|
1761 * @return 0 on success, negative AVERROR on failure.
|
yading@11
|
1762 *
|
yading@11
|
1763 * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
|
yading@11
|
1764 */
|
yading@11
|
1765 int avformat_write_header(AVFormatContext *s, AVDictionary **options);
|
yading@11
|
1766
|
yading@11
|
1767 /**
|
yading@11
|
1768 * Write a packet to an output media file.
|
yading@11
|
1769 *
|
yading@11
|
1770 * The packet shall contain one audio or video frame.
|
yading@11
|
1771 * The packet must be correctly interleaved according to the container
|
yading@11
|
1772 * specification, if not then av_interleaved_write_frame must be used.
|
yading@11
|
1773 *
|
yading@11
|
1774 * @param s media file handle
|
yading@11
|
1775 * @param pkt The packet, which contains the stream_index, buf/buf_size,
|
yading@11
|
1776 * dts/pts, ...
|
yading@11
|
1777 * This can be NULL (at any time, not just at the end), in
|
yading@11
|
1778 * order to immediately flush data buffered within the muxer,
|
yading@11
|
1779 * for muxers that buffer up data internally before writing it
|
yading@11
|
1780 * to the output.
|
yading@11
|
1781 * @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush
|
yading@11
|
1782 */
|
yading@11
|
1783 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
|
yading@11
|
1784
|
yading@11
|
1785 /**
|
yading@11
|
1786 * Write a packet to an output media file ensuring correct interleaving.
|
yading@11
|
1787 *
|
yading@11
|
1788 * The packet must contain one audio or video frame.
|
yading@11
|
1789 * If the packets are already correctly interleaved, the application should
|
yading@11
|
1790 * call av_write_frame() instead as it is slightly faster. It is also important
|
yading@11
|
1791 * to keep in mind that completely non-interleaved input will need huge amounts
|
yading@11
|
1792 * of memory to interleave with this, so it is preferable to interleave at the
|
yading@11
|
1793 * demuxer level.
|
yading@11
|
1794 *
|
yading@11
|
1795 * @param s media file handle
|
yading@11
|
1796 * @param pkt The packet containing the data to be written. pkt->buf must be set
|
yading@11
|
1797 * to a valid AVBufferRef describing the packet data. Libavformat takes
|
yading@11
|
1798 * ownership of this reference and will unref it when it sees fit. The caller
|
yading@11
|
1799 * must not access the data through this reference after this function returns.
|
yading@11
|
1800 * This can be NULL (at any time, not just at the end), to flush the
|
yading@11
|
1801 * interleaving queues.
|
yading@11
|
1802 * Packet's @ref AVPacket.stream_index "stream_index" field must be set to the
|
yading@11
|
1803 * index of the corresponding stream in @ref AVFormatContext.streams
|
yading@11
|
1804 * "s.streams".
|
yading@11
|
1805 * It is very strongly recommended that timing information (@ref AVPacket.pts
|
yading@11
|
1806 * "pts", @ref AVPacket.dts "dts" @ref AVPacket.duration "duration") is set to
|
yading@11
|
1807 * correct values.
|
yading@11
|
1808 *
|
yading@11
|
1809 * @return 0 on success, a negative AVERROR on error.
|
yading@11
|
1810 */
|
yading@11
|
1811 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
|
yading@11
|
1812
|
yading@11
|
1813 /**
|
yading@11
|
1814 * Write the stream trailer to an output media file and free the
|
yading@11
|
1815 * file private data.
|
yading@11
|
1816 *
|
yading@11
|
1817 * May only be called after a successful call to avformat_write_header.
|
yading@11
|
1818 *
|
yading@11
|
1819 * @param s media file handle
|
yading@11
|
1820 * @return 0 if OK, AVERROR_xxx on error
|
yading@11
|
1821 */
|
yading@11
|
1822 int av_write_trailer(AVFormatContext *s);
|
yading@11
|
1823
|
yading@11
|
1824 /**
|
yading@11
|
1825 * Return the output format in the list of registered output formats
|
yading@11
|
1826 * which best matches the provided parameters, or return NULL if
|
yading@11
|
1827 * there is no match.
|
yading@11
|
1828 *
|
yading@11
|
1829 * @param short_name if non-NULL checks if short_name matches with the
|
yading@11
|
1830 * names of the registered formats
|
yading@11
|
1831 * @param filename if non-NULL checks if filename terminates with the
|
yading@11
|
1832 * extensions of the registered formats
|
yading@11
|
1833 * @param mime_type if non-NULL checks if mime_type matches with the
|
yading@11
|
1834 * MIME type of the registered formats
|
yading@11
|
1835 */
|
yading@11
|
1836 AVOutputFormat *av_guess_format(const char *short_name,
|
yading@11
|
1837 const char *filename,
|
yading@11
|
1838 const char *mime_type);
|
yading@11
|
1839
|
yading@11
|
1840 /**
|
yading@11
|
1841 * Guess the codec ID based upon muxer and filename.
|
yading@11
|
1842 */
|
yading@11
|
1843 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
|
yading@11
|
1844 const char *filename, const char *mime_type,
|
yading@11
|
1845 enum AVMediaType type);
|
yading@11
|
1846
|
yading@11
|
1847 /**
|
yading@11
|
1848 * Get timing information for the data currently output.
|
yading@11
|
1849 * The exact meaning of "currently output" depends on the format.
|
yading@11
|
1850 * It is mostly relevant for devices that have an internal buffer and/or
|
yading@11
|
1851 * work in real time.
|
yading@11
|
1852 * @param s media file handle
|
yading@11
|
1853 * @param stream stream in the media file
|
yading@11
|
1854 * @param[out] dts DTS of the last packet output for the stream, in stream
|
yading@11
|
1855 * time_base units
|
yading@11
|
1856 * @param[out] wall absolute time when that packet whas output,
|
yading@11
|
1857 * in microsecond
|
yading@11
|
1858 * @return 0 if OK, AVERROR(ENOSYS) if the format does not support it
|
yading@11
|
1859 * Note: some formats or devices may not allow to measure dts and wall
|
yading@11
|
1860 * atomically.
|
yading@11
|
1861 */
|
yading@11
|
1862 int av_get_output_timestamp(struct AVFormatContext *s, int stream,
|
yading@11
|
1863 int64_t *dts, int64_t *wall);
|
yading@11
|
1864
|
yading@11
|
1865
|
yading@11
|
1866 /**
|
yading@11
|
1867 * @}
|
yading@11
|
1868 */
|
yading@11
|
1869
|
yading@11
|
1870
|
yading@11
|
1871 /**
|
yading@11
|
1872 * @defgroup lavf_misc Utility functions
|
yading@11
|
1873 * @ingroup libavf
|
yading@11
|
1874 * @{
|
yading@11
|
1875 *
|
yading@11
|
1876 * Miscellaneous utility functions related to both muxing and demuxing
|
yading@11
|
1877 * (or neither).
|
yading@11
|
1878 */
|
yading@11
|
1879
|
yading@11
|
1880 /**
|
yading@11
|
1881 * Send a nice hexadecimal dump of a buffer to the specified file stream.
|
yading@11
|
1882 *
|
yading@11
|
1883 * @param f The file stream pointer where the dump should be sent to.
|
yading@11
|
1884 * @param buf buffer
|
yading@11
|
1885 * @param size buffer size
|
yading@11
|
1886 *
|
yading@11
|
1887 * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2
|
yading@11
|
1888 */
|
yading@11
|
1889 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
|
yading@11
|
1890
|
yading@11
|
1891 /**
|
yading@11
|
1892 * Send a nice hexadecimal dump of a buffer to the log.
|
yading@11
|
1893 *
|
yading@11
|
1894 * @param avcl A pointer to an arbitrary struct of which the first field is a
|
yading@11
|
1895 * pointer to an AVClass struct.
|
yading@11
|
1896 * @param level The importance level of the message, lower values signifying
|
yading@11
|
1897 * higher importance.
|
yading@11
|
1898 * @param buf buffer
|
yading@11
|
1899 * @param size buffer size
|
yading@11
|
1900 *
|
yading@11
|
1901 * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2
|
yading@11
|
1902 */
|
yading@11
|
1903 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
|
yading@11
|
1904
|
yading@11
|
1905 /**
|
yading@11
|
1906 * Send a nice dump of a packet to the specified file stream.
|
yading@11
|
1907 *
|
yading@11
|
1908 * @param f The file stream pointer where the dump should be sent to.
|
yading@11
|
1909 * @param pkt packet to dump
|
yading@11
|
1910 * @param dump_payload True if the payload must be displayed, too.
|
yading@11
|
1911 * @param st AVStream that the packet belongs to
|
yading@11
|
1912 */
|
yading@11
|
1913 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
|
yading@11
|
1914
|
yading@11
|
1915
|
yading@11
|
1916 /**
|
yading@11
|
1917 * Send a nice dump of a packet to the log.
|
yading@11
|
1918 *
|
yading@11
|
1919 * @param avcl A pointer to an arbitrary struct of which the first field is a
|
yading@11
|
1920 * pointer to an AVClass struct.
|
yading@11
|
1921 * @param level The importance level of the message, lower values signifying
|
yading@11
|
1922 * higher importance.
|
yading@11
|
1923 * @param pkt packet to dump
|
yading@11
|
1924 * @param dump_payload True if the payload must be displayed, too.
|
yading@11
|
1925 * @param st AVStream that the packet belongs to
|
yading@11
|
1926 */
|
yading@11
|
1927 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
|
yading@11
|
1928 AVStream *st);
|
yading@11
|
1929
|
yading@11
|
1930 /**
|
yading@11
|
1931 * Get the AVCodecID for the given codec tag tag.
|
yading@11
|
1932 * If no codec id is found returns AV_CODEC_ID_NONE.
|
yading@11
|
1933 *
|
yading@11
|
1934 * @param tags list of supported codec_id-codec_tag pairs, as stored
|
yading@11
|
1935 * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
|
yading@11
|
1936 */
|
yading@11
|
1937 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
|
yading@11
|
1938
|
yading@11
|
1939 /**
|
yading@11
|
1940 * Get the codec tag for the given codec id id.
|
yading@11
|
1941 * If no codec tag is found returns 0.
|
yading@11
|
1942 *
|
yading@11
|
1943 * @param tags list of supported codec_id-codec_tag pairs, as stored
|
yading@11
|
1944 * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
|
yading@11
|
1945 */
|
yading@11
|
1946 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
|
yading@11
|
1947
|
yading@11
|
1948 /**
|
yading@11
|
1949 * Get the codec tag for the given codec id.
|
yading@11
|
1950 *
|
yading@11
|
1951 * @param tags list of supported codec_id - codec_tag pairs, as stored
|
yading@11
|
1952 * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
|
yading@11
|
1953 * @param id codec id that should be searched for in the list
|
yading@11
|
1954 * @param tag A pointer to the found tag
|
yading@11
|
1955 * @return 0 if id was not found in tags, > 0 if it was found
|
yading@11
|
1956 */
|
yading@11
|
1957 int av_codec_get_tag2(const struct AVCodecTag * const *tags, enum AVCodecID id,
|
yading@11
|
1958 unsigned int *tag);
|
yading@11
|
1959
|
yading@11
|
1960 int av_find_default_stream_index(AVFormatContext *s);
|
yading@11
|
1961
|
yading@11
|
1962 /**
|
yading@11
|
1963 * Get the index for a specific timestamp.
|
yading@11
|
1964 * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
|
yading@11
|
1965 * to the timestamp which is <= the requested one, if backward
|
yading@11
|
1966 * is 0, then it will be >=
|
yading@11
|
1967 * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
|
yading@11
|
1968 * @return < 0 if no such timestamp could be found
|
yading@11
|
1969 */
|
yading@11
|
1970 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
|
yading@11
|
1971
|
yading@11
|
1972 /**
|
yading@11
|
1973 * Add an index entry into a sorted list. Update the entry if the list
|
yading@11
|
1974 * already contains it.
|
yading@11
|
1975 *
|
yading@11
|
1976 * @param timestamp timestamp in the time base of the given stream
|
yading@11
|
1977 */
|
yading@11
|
1978 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
|
yading@11
|
1979 int size, int distance, int flags);
|
yading@11
|
1980
|
yading@11
|
1981
|
yading@11
|
1982 /**
|
yading@11
|
1983 * Split a URL string into components.
|
yading@11
|
1984 *
|
yading@11
|
1985 * The pointers to buffers for storing individual components may be null,
|
yading@11
|
1986 * in order to ignore that component. Buffers for components not found are
|
yading@11
|
1987 * set to empty strings. If the port is not found, it is set to a negative
|
yading@11
|
1988 * value.
|
yading@11
|
1989 *
|
yading@11
|
1990 * @param proto the buffer for the protocol
|
yading@11
|
1991 * @param proto_size the size of the proto buffer
|
yading@11
|
1992 * @param authorization the buffer for the authorization
|
yading@11
|
1993 * @param authorization_size the size of the authorization buffer
|
yading@11
|
1994 * @param hostname the buffer for the host name
|
yading@11
|
1995 * @param hostname_size the size of the hostname buffer
|
yading@11
|
1996 * @param port_ptr a pointer to store the port number in
|
yading@11
|
1997 * @param path the buffer for the path
|
yading@11
|
1998 * @param path_size the size of the path buffer
|
yading@11
|
1999 * @param url the URL to split
|
yading@11
|
2000 */
|
yading@11
|
2001 void av_url_split(char *proto, int proto_size,
|
yading@11
|
2002 char *authorization, int authorization_size,
|
yading@11
|
2003 char *hostname, int hostname_size,
|
yading@11
|
2004 int *port_ptr,
|
yading@11
|
2005 char *path, int path_size,
|
yading@11
|
2006 const char *url);
|
yading@11
|
2007
|
yading@11
|
2008
|
yading@11
|
2009 void av_dump_format(AVFormatContext *ic,
|
yading@11
|
2010 int index,
|
yading@11
|
2011 const char *url,
|
yading@11
|
2012 int is_output);
|
yading@11
|
2013
|
yading@11
|
2014 /**
|
yading@11
|
2015 * Return in 'buf' the path with '%d' replaced by a number.
|
yading@11
|
2016 *
|
yading@11
|
2017 * Also handles the '%0nd' format where 'n' is the total number
|
yading@11
|
2018 * of digits and '%%'.
|
yading@11
|
2019 *
|
yading@11
|
2020 * @param buf destination buffer
|
yading@11
|
2021 * @param buf_size destination buffer size
|
yading@11
|
2022 * @param path numbered sequence string
|
yading@11
|
2023 * @param number frame number
|
yading@11
|
2024 * @return 0 if OK, -1 on format error
|
yading@11
|
2025 */
|
yading@11
|
2026 int av_get_frame_filename(char *buf, int buf_size,
|
yading@11
|
2027 const char *path, int number);
|
yading@11
|
2028
|
yading@11
|
2029 /**
|
yading@11
|
2030 * Check whether filename actually is a numbered sequence generator.
|
yading@11
|
2031 *
|
yading@11
|
2032 * @param filename possible numbered sequence string
|
yading@11
|
2033 * @return 1 if a valid numbered sequence string, 0 otherwise
|
yading@11
|
2034 */
|
yading@11
|
2035 int av_filename_number_test(const char *filename);
|
yading@11
|
2036
|
yading@11
|
2037 /**
|
yading@11
|
2038 * Generate an SDP for an RTP session.
|
yading@11
|
2039 *
|
yading@11
|
2040 * Note, this overwrites the id values of AVStreams in the muxer contexts
|
yading@11
|
2041 * for getting unique dynamic payload types.
|
yading@11
|
2042 *
|
yading@11
|
2043 * @param ac array of AVFormatContexts describing the RTP streams. If the
|
yading@11
|
2044 * array is composed by only one context, such context can contain
|
yading@11
|
2045 * multiple AVStreams (one AVStream per RTP stream). Otherwise,
|
yading@11
|
2046 * all the contexts in the array (an AVCodecContext per RTP stream)
|
yading@11
|
2047 * must contain only one AVStream.
|
yading@11
|
2048 * @param n_files number of AVCodecContexts contained in ac
|
yading@11
|
2049 * @param buf buffer where the SDP will be stored (must be allocated by
|
yading@11
|
2050 * the caller)
|
yading@11
|
2051 * @param size the size of the buffer
|
yading@11
|
2052 * @return 0 if OK, AVERROR_xxx on error
|
yading@11
|
2053 */
|
yading@11
|
2054 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
|
yading@11
|
2055
|
yading@11
|
2056 /**
|
yading@11
|
2057 * Return a positive value if the given filename has one of the given
|
yading@11
|
2058 * extensions, 0 otherwise.
|
yading@11
|
2059 *
|
yading@11
|
2060 * @param extensions a comma-separated list of filename extensions
|
yading@11
|
2061 */
|
yading@11
|
2062 int av_match_ext(const char *filename, const char *extensions);
|
yading@11
|
2063
|
yading@11
|
2064 /**
|
yading@11
|
2065 * Test if the given container can store a codec.
|
yading@11
|
2066 *
|
yading@11
|
2067 * @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
|
yading@11
|
2068 *
|
yading@11
|
2069 * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
|
yading@11
|
2070 * A negative number if this information is not available.
|
yading@11
|
2071 */
|
yading@11
|
2072 int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance);
|
yading@11
|
2073
|
yading@11
|
2074 /**
|
yading@11
|
2075 * @defgroup riff_fourcc RIFF FourCCs
|
yading@11
|
2076 * @{
|
yading@11
|
2077 * Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are
|
yading@11
|
2078 * meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the
|
yading@11
|
2079 * following code:
|
yading@11
|
2080 * @code
|
yading@11
|
2081 * uint32_t tag = MKTAG('H', '2', '6', '4');
|
yading@11
|
2082 * const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 };
|
yading@11
|
2083 * enum AVCodecID id = av_codec_get_id(table, tag);
|
yading@11
|
2084 * @endcode
|
yading@11
|
2085 */
|
yading@11
|
2086 /**
|
yading@11
|
2087 * @return the table mapping RIFF FourCCs for video to libavcodec AVCodecID.
|
yading@11
|
2088 */
|
yading@11
|
2089 const struct AVCodecTag *avformat_get_riff_video_tags(void);
|
yading@11
|
2090 /**
|
yading@11
|
2091 * @return the table mapping RIFF FourCCs for audio to AVCodecID.
|
yading@11
|
2092 */
|
yading@11
|
2093 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
|
yading@11
|
2094
|
yading@11
|
2095 /**
|
yading@11
|
2096 * @}
|
yading@11
|
2097 */
|
yading@11
|
2098
|
yading@11
|
2099 /**
|
yading@11
|
2100 * Guess the sample aspect ratio of a frame, based on both the stream and the
|
yading@11
|
2101 * frame aspect ratio.
|
yading@11
|
2102 *
|
yading@11
|
2103 * Since the frame aspect ratio is set by the codec but the stream aspect ratio
|
yading@11
|
2104 * is set by the demuxer, these two may not be equal. This function tries to
|
yading@11
|
2105 * return the value that you should use if you would like to display the frame.
|
yading@11
|
2106 *
|
yading@11
|
2107 * Basic logic is to use the stream aspect ratio if it is set to something sane
|
yading@11
|
2108 * otherwise use the frame aspect ratio. This way a container setting, which is
|
yading@11
|
2109 * usually easy to modify can override the coded value in the frames.
|
yading@11
|
2110 *
|
yading@11
|
2111 * @param format the format context which the stream is part of
|
yading@11
|
2112 * @param stream the stream which the frame is part of
|
yading@11
|
2113 * @param frame the frame with the aspect ratio to be determined
|
yading@11
|
2114 * @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea
|
yading@11
|
2115 */
|
yading@11
|
2116 AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame);
|
yading@11
|
2117
|
yading@11
|
2118 /**
|
yading@11
|
2119 * Guess the frame rate, based on both the container and codec information.
|
yading@11
|
2120 *
|
yading@11
|
2121 * @param ctx the format context which the stream is part of
|
yading@11
|
2122 * @param stream the stream which the frame is part of
|
yading@11
|
2123 * @param frame the frame for which the frame rate should be determined, may be NULL
|
yading@11
|
2124 * @return the guessed (valid) frame rate, 0/1 if no idea
|
yading@11
|
2125 */
|
yading@11
|
2126 AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame);
|
yading@11
|
2127
|
yading@11
|
2128 /**
|
yading@11
|
2129 * Check if the stream st contained in s is matched by the stream specifier
|
yading@11
|
2130 * spec.
|
yading@11
|
2131 *
|
yading@11
|
2132 * See the "stream specifiers" chapter in the documentation for the syntax
|
yading@11
|
2133 * of spec.
|
yading@11
|
2134 *
|
yading@11
|
2135 * @return >0 if st is matched by spec;
|
yading@11
|
2136 * 0 if st is not matched by spec;
|
yading@11
|
2137 * AVERROR code if spec is invalid
|
yading@11
|
2138 *
|
yading@11
|
2139 * @note A stream specifier can match several streams in the format.
|
yading@11
|
2140 */
|
yading@11
|
2141 int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
|
yading@11
|
2142 const char *spec);
|
yading@11
|
2143
|
yading@11
|
2144 int avformat_queue_attached_pictures(AVFormatContext *s);
|
yading@11
|
2145
|
yading@11
|
2146
|
yading@11
|
2147 /**
|
yading@11
|
2148 * @}
|
yading@11
|
2149 */
|
yading@11
|
2150
|
yading@11
|
2151 #endif /* AVFORMAT_AVFORMAT_H */
|