00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVFORMAT_AVFORMAT_H
00022 #define AVFORMAT_AVFORMAT_H
00023
00024 #define LIBAVFORMAT_VERSION_MAJOR 52
00025 #define LIBAVFORMAT_VERSION_MINOR 64
00026 #define LIBAVFORMAT_VERSION_MICRO 2
00027
00028 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
00029 LIBAVFORMAT_VERSION_MINOR, \
00030 LIBAVFORMAT_VERSION_MICRO)
00031 #define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
00032 LIBAVFORMAT_VERSION_MINOR, \
00033 LIBAVFORMAT_VERSION_MICRO)
00034 #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
00035
00036 #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
00037
00042 unsigned avformat_version(void);
00043
00047 const char *avformat_configuration(void);
00048
00052 const char *avformat_license(void);
00053
00054 #include <time.h>
00055 #include <stdio.h>
00056 #include "libavcodec/avcodec.h"
00057
00058 #include "avio.h"
00059
00060 struct AVFormatContext;
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 #define AV_METADATA_MATCH_CASE 1
00119 #define AV_METADATA_IGNORE_SUFFIX 2
00120 #define AV_METADATA_DONT_STRDUP_KEY 4
00121 #define AV_METADATA_DONT_STRDUP_VAL 8
00122 #define AV_METADATA_DONT_OVERWRITE 16 ///< Don't overwrite existing tags.
00123
00124 typedef struct {
00125 char *key;
00126 char *value;
00127 }AVMetadataTag;
00128
00129 typedef struct AVMetadata AVMetadata;
00130 typedef struct AVMetadataConv AVMetadataConv;
00131
00139 AVMetadataTag *
00140 av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
00141
00142 #if LIBAVFORMAT_VERSION_MAJOR == 52
00143
00150 attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
00151 #endif
00152
00159 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
00160
00168 void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv,
00169 const AVMetadataConv *s_conv);
00170
00174 void av_metadata_free(AVMetadata **m);
00175
00176
00177
00178
00179
00188 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
00189
00190
00191
00192
00193
00198 typedef struct AVFrac {
00199 int64_t val, num, den;
00200 } AVFrac;
00201
00202
00203
00204
00205 struct AVCodecTag;
00206
00208 typedef struct AVProbeData {
00209 const char *filename;
00210 unsigned char *buf;
00211 int buf_size;
00212 } AVProbeData;
00213
00214 #define AVPROBE_SCORE_MAX 100 ///< maximum score, half of that is used for file-extension-based detection
00215 #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer
00216
00217 typedef struct AVFormatParameters {
00218 AVRational time_base;
00219 int sample_rate;
00220 int channels;
00221 int width;
00222 int height;
00223 enum PixelFormat pix_fmt;
00224 int channel;
00225 const char *standard;
00226 unsigned int mpeg2ts_raw:1;
00227 unsigned int mpeg2ts_compute_pcr:1;
00230 unsigned int initial_pause:1;
00232 unsigned int prealloced_context:1;
00233 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00234 enum CodecID video_codec_id;
00235 enum CodecID audio_codec_id;
00236 #endif
00237 } AVFormatParameters;
00238
00240 #define AVFMT_NOFILE 0x0001
00241 #define AVFMT_NEEDNUMBER 0x0002
00242 #define AVFMT_SHOW_IDS 0x0008
00243 #define AVFMT_RAWPICTURE 0x0020
00245 #define AVFMT_GLOBALHEADER 0x0040
00246 #define AVFMT_NOTIMESTAMPS 0x0080
00247 #define AVFMT_GENERIC_INDEX 0x0100
00248 #define AVFMT_TS_DISCONT 0x0200
00249 #define AVFMT_VARIABLE_FPS 0x0400
00250 #define AVFMT_NODIMENSIONS 0x0800
00252 typedef struct AVOutputFormat {
00253 const char *name;
00259 const char *long_name;
00260 const char *mime_type;
00261 const char *extensions;
00263 int priv_data_size;
00264
00265 enum CodecID audio_codec;
00266 enum CodecID video_codec;
00267 int (*write_header)(struct AVFormatContext *);
00268 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00269 int (*write_trailer)(struct AVFormatContext *);
00271 int flags;
00273 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00274 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
00275 AVPacket *in, int flush);
00276
00281 const struct AVCodecTag * const *codec_tag;
00282
00283 enum CodecID subtitle_codec;
00285 const AVMetadataConv *metadata_conv;
00286
00287
00288 struct AVOutputFormat *next;
00289 } AVOutputFormat;
00290
00291 typedef struct AVInputFormat {
00292 const char *name;
00298 const char *long_name;
00300 int priv_data_size;
00306 int (*read_probe)(AVProbeData *);
00311 int (*read_header)(struct AVFormatContext *,
00312 AVFormatParameters *ap);
00319 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00322 int (*read_close)(struct AVFormatContext *);
00323
00324 #if LIBAVFORMAT_VERSION_MAJOR < 53
00325
00333 int (*read_seek)(struct AVFormatContext *,
00334 int stream_index, int64_t timestamp, int flags);
00335 #endif
00336
00340 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
00341 int64_t *pos, int64_t pos_limit);
00343 int flags;
00347 const char *extensions;
00349 int value;
00350
00353 int (*read_play)(struct AVFormatContext *);
00354
00357 int (*read_pause)(struct AVFormatContext *);
00358
00359 const struct AVCodecTag * const *codec_tag;
00360
00367 int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
00368
00369 const AVMetadataConv *metadata_conv;
00370
00371
00372 struct AVInputFormat *next;
00373 } AVInputFormat;
00374
00375 enum AVStreamParseType {
00376 AVSTREAM_PARSE_NONE,
00377 AVSTREAM_PARSE_FULL,
00378 AVSTREAM_PARSE_HEADERS,
00379 AVSTREAM_PARSE_TIMESTAMPS,
00380 };
00381
00382 typedef struct AVIndexEntry {
00383 int64_t pos;
00384 int64_t timestamp;
00385 #define AVINDEX_KEYFRAME 0x0001
00386 int flags:2;
00387 int size:30;
00388 int min_distance;
00389 } AVIndexEntry;
00390
00391 #define AV_DISPOSITION_DEFAULT 0x0001
00392 #define AV_DISPOSITION_DUB 0x0002
00393 #define AV_DISPOSITION_ORIGINAL 0x0004
00394 #define AV_DISPOSITION_COMMENT 0x0008
00395 #define AV_DISPOSITION_LYRICS 0x0010
00396 #define AV_DISPOSITION_KARAOKE 0x0020
00397
00405 typedef struct AVStream {
00406 int index;
00407 int id;
00408 AVCodecContext *codec;
00417 AVRational r_frame_rate;
00418 void *priv_data;
00419
00420
00421 int64_t first_dts;
00423 struct AVFrac pts;
00424
00430 AVRational time_base;
00431 int pts_wrap_bits;
00432
00433 int stream_copy;
00434 enum AVDiscard discard;
00435
00438 float quality;
00447 int64_t start_time;
00453 int64_t duration;
00454
00455 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00456 char language[4];
00457 #endif
00458
00459
00460 enum AVStreamParseType need_parsing;
00461 struct AVCodecParserContext *parser;
00462
00463 int64_t cur_dts;
00464 int last_IP_duration;
00465 int64_t last_IP_pts;
00466
00467 AVIndexEntry *index_entries;
00469 int nb_index_entries;
00470 unsigned int index_entries_allocated_size;
00471
00472 int64_t nb_frames;
00473
00474 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00475 int64_t unused[4+1];
00476
00477 char *filename;
00478 #endif
00479
00480 int disposition;
00482 AVProbeData probe_data;
00483 #define MAX_REORDER_DELAY 16
00484 int64_t pts_buffer[MAX_REORDER_DELAY+1];
00485
00491 AVRational sample_aspect_ratio;
00492
00493 AVMetadata *metadata;
00494
00495
00496 const uint8_t *cur_ptr;
00497 int cur_len;
00498 AVPacket cur_pkt;
00499
00500
00508 int64_t reference_dts;
00509
00514 #define MAX_PROBE_PACKETS 2500
00515 int probe_packets;
00516
00521 struct AVPacketList *last_in_packet_buffer;
00522
00526 AVRational avg_frame_rate;
00527
00531 int codec_info_nb_frames;
00532 } AVStream;
00533
00534 #define AV_PROGRAM_RUNNING 1
00535
00542 typedef struct AVProgram {
00543 int id;
00544 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00545 char *provider_name;
00546 char *name;
00547 #endif
00548 int flags;
00549 enum AVDiscard discard;
00550 unsigned int *stream_index;
00551 unsigned int nb_stream_indexes;
00552 AVMetadata *metadata;
00553 } AVProgram;
00554
00555 #define AVFMTCTX_NOHEADER 0x0001
00558 typedef struct AVChapter {
00559 int id;
00560 AVRational time_base;
00561 int64_t start, end;
00562 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00563 char *title;
00564 #endif
00565 AVMetadata *metadata;
00566 } AVChapter;
00567
00568 #if LIBAVFORMAT_VERSION_MAJOR < 53
00569 #define MAX_STREAMS 20
00570 #else
00571 #define MAX_STREAMS 100
00572 #endif
00573
00581 typedef struct AVFormatContext {
00582 const AVClass *av_class;
00583
00584 struct AVInputFormat *iformat;
00585 struct AVOutputFormat *oformat;
00586 void *priv_data;
00587 ByteIOContext *pb;
00588 unsigned int nb_streams;
00589 AVStream *streams[MAX_STREAMS];
00590 char filename[1024];
00591
00592 int64_t timestamp;
00593 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00594 char title[512];
00595 char author[512];
00596 char copyright[512];
00597 char comment[512];
00598 char album[512];
00599 int year;
00600 int track;
00601 char genre[32];
00602 #endif
00603
00604 int ctx_flags;
00605
00609 struct AVPacketList *packet_buffer;
00610
00614 int64_t start_time;
00619 int64_t duration;
00621 int64_t file_size;
00625 int bit_rate;
00626
00627
00628 AVStream *cur_st;
00629 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00630 const uint8_t *cur_ptr_deprecated;
00631 int cur_len_deprecated;
00632 AVPacket cur_pkt_deprecated;
00633 #endif
00634
00635
00636 int64_t data_offset;
00637 int index_built;
00638
00639 int mux_rate;
00640 unsigned int packet_size;
00641 int preload;
00642 int max_delay;
00643
00644 #define AVFMT_NOOUTPUTLOOP -1
00645 #define AVFMT_INFINITEOUTPUTLOOP 0
00646
00647 int loop_output;
00648
00649 int flags;
00650 #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
00651 #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
00652 #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
00653 #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
00654 #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
00655 #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
00656 #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Add RTP hinting to the output file
00657
00658 int loop_input;
00660 unsigned int probesize;
00661
00666 int max_analyze_duration;
00667
00668 const uint8_t *key;
00669 int keylen;
00670
00671 unsigned int nb_programs;
00672 AVProgram **programs;
00673
00678 enum CodecID video_codec_id;
00683 enum CodecID audio_codec_id;
00688 enum CodecID subtitle_codec_id;
00689
00700 unsigned int max_index_size;
00701
00706 unsigned int max_picture_buffer;
00707
00708 unsigned int nb_chapters;
00709 AVChapter **chapters;
00710
00714 int debug;
00715 #define FF_FDEBUG_TS 0x0001
00716
00723 struct AVPacketList *raw_packet_buffer;
00724 struct AVPacketList *raw_packet_buffer_end;
00725
00726 struct AVPacketList *packet_buffer_end;
00727
00728 AVMetadata *metadata;
00729
00734 #define RAW_PACKET_BUFFER_SIZE 2500000
00735 int raw_packet_buffer_remaining_size;
00736
00744 int64_t start_time_realtime;
00745 } AVFormatContext;
00746
00747 typedef struct AVPacketList {
00748 AVPacket pkt;
00749 struct AVPacketList *next;
00750 } AVPacketList;
00751
00752 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00753 extern AVInputFormat *first_iformat;
00754 extern AVOutputFormat *first_oformat;
00755 #endif
00756
00762 AVInputFormat *av_iformat_next(AVInputFormat *f);
00763
00769 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
00770
00771 enum CodecID av_guess_image2_codec(const char *filename);
00772
00773
00774
00775
00776
00777 void av_register_input_format(AVInputFormat *format);
00778 void av_register_output_format(AVOutputFormat *format);
00779 #if LIBAVFORMAT_VERSION_MAJOR < 53
00780 attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name,
00781 const char *filename,
00782 const char *mime_type);
00783
00787 attribute_deprecated AVOutputFormat *guess_format(const char *short_name,
00788 const char *filename,
00789 const char *mime_type);
00790 #endif
00791
00804 AVOutputFormat *av_guess_format(const char *short_name,
00805 const char *filename,
00806 const char *mime_type);
00807
00811 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
00812 const char *filename, const char *mime_type,
00813 enum AVMediaType type);
00814
00824 void av_hex_dump(FILE *f, uint8_t *buf, int size);
00825
00838 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
00839
00847 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
00848
00859 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
00860
00870 void av_register_all(void);
00871
00873 enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
00874 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
00875
00876
00877
00881 AVInputFormat *av_find_input_format(const char *short_name);
00882
00889 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
00890
00902 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
00903
00908 int av_open_input_stream(AVFormatContext **ic_ptr,
00909 ByteIOContext *pb, const char *filename,
00910 AVInputFormat *fmt, AVFormatParameters *ap);
00911
00924 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
00925 AVInputFormat *fmt,
00926 int buf_size,
00927 AVFormatParameters *ap);
00928
00929 #if LIBAVFORMAT_VERSION_MAJOR < 53
00930
00933 attribute_deprecated AVFormatContext *av_alloc_format_context(void);
00934 #endif
00935
00941 AVFormatContext *avformat_alloc_context(void);
00942
00956 int av_find_stream_info(AVFormatContext *ic);
00957
00968 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
00969
00989 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
00990
01002 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
01003 int flags);
01004
01031 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
01032
01037 int av_read_play(AVFormatContext *s);
01038
01044 int av_read_pause(AVFormatContext *s);
01045
01050 void av_close_input_stream(AVFormatContext *s);
01051
01057 void av_close_input_file(AVFormatContext *s);
01058
01069 AVStream *av_new_stream(AVFormatContext *s, int id);
01070 AVProgram *av_new_program(AVFormatContext *s, int id);
01071
01085 AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
01086 int64_t start, int64_t end, const char *title);
01087
01097 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
01098 unsigned int pts_num, unsigned int pts_den);
01099
01100 #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
01101 #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
01102 #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes
01103 #define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number
01104
01105 int av_find_default_stream_index(AVFormatContext *s);
01106
01115 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
01116
01124 void ff_reduce_index(AVFormatContext *s, int stream_index);
01125
01132 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
01133 int size, int distance, int flags);
01134
01143 int av_seek_frame_binary(AVFormatContext *s, int stream_index,
01144 int64_t target_ts, int flags);
01145
01154 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
01155
01163 int64_t av_gen_search(AVFormatContext *s, int stream_index,
01164 int64_t target_ts, int64_t pos_min,
01165 int64_t pos_max, int64_t pos_limit,
01166 int64_t ts_min, int64_t ts_max,
01167 int flags, int64_t *ts_ret,
01168 int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
01169
01171 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
01172
01180 int av_write_header(AVFormatContext *s);
01181
01194 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
01195
01211 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
01212
01228 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
01229 AVPacket *pkt, int flush);
01230
01240 int av_write_trailer(AVFormatContext *s);
01241
01242 void dump_format(AVFormatContext *ic,
01243 int index,
01244 const char *url,
01245 int is_output);
01246
01247 #if LIBAVFORMAT_VERSION_MAJOR < 53
01248
01252 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
01253 const char *str);
01254
01259 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
01260 const char *arg);
01261 #endif
01262
01289 int64_t parse_date(const char *datestr, int duration);
01290
01292 int64_t av_gettime(void);
01293
01294
01295 #define FFM_PACKET_SIZE 4096
01296 int64_t ffm_read_write_index(int fd);
01297 int ffm_write_write_index(int fd, int64_t pos);
01298 void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
01299
01306 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
01307
01320 int av_get_frame_filename(char *buf, int buf_size,
01321 const char *path, int number);
01322
01329 int av_filename_number_test(const char *filename);
01330
01345 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
01346
01353 int av_match_ext(const char *filename, const char *extensions);
01354
01355 #endif