OpenFFmpeg
avformat.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVFORMAT_AVFORMAT_H
22 #define AVFORMAT_AVFORMAT_H
23 
317 #include <time.h>
318 #include <stdio.h> /* FILE */
319 #include "libavcodec/avcodec.h"
320 #include "libavutil/dict.h"
321 #include "libavutil/log.h"
322 
323 #include "avio.h"
324 #include "libavformat/version.h"
325 
326 struct AVFormatContext;
327 
328 struct AVDeviceInfoList;
330 
409 /* packet functions */
410 
411 
421 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
422 
423 
438 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
439 
440 /*************************************************/
441 /* input/output formats */
442 
443 struct AVCodecTag;
444 
448 typedef struct AVProbeData {
449  const char *filename;
450  unsigned char *buf;
451  int buf_size;
452  const char *mime_type;
453 } AVProbeData;
454 
455 #define AVPROBE_SCORE_RETRY (AVPROBE_SCORE_MAX/4)
456 #define AVPROBE_SCORE_STREAM_RETRY (AVPROBE_SCORE_MAX/4-1)
457 
458 #define AVPROBE_SCORE_EXTENSION 50
459 #define AVPROBE_SCORE_MIME 75
460 #define AVPROBE_SCORE_MAX 100
461 
462 #define AVPROBE_PADDING_SIZE 32
463 
464 #define AVFMT_NOFILE 0x0001
466 #define AVFMT_NEEDNUMBER 0x0002
467 #define AVFMT_SHOW_IDS 0x0008
468 #define AVFMT_GLOBALHEADER 0x0040
469 #define AVFMT_NOTIMESTAMPS 0x0080
470 #define AVFMT_GENERIC_INDEX 0x0100
471 #define AVFMT_TS_DISCONT 0x0200
472 #define AVFMT_VARIABLE_FPS 0x0400
473 #define AVFMT_NODIMENSIONS 0x0800
474 #define AVFMT_NOSTREAMS 0x1000
475 #define AVFMT_NOBINSEARCH 0x2000
476 #define AVFMT_NOGENSEARCH 0x4000
477 #define AVFMT_NO_BYTE_SEEK 0x8000
478 #define AVFMT_ALLOW_FLUSH 0x10000
479 #define AVFMT_TS_NONSTRICT 0x20000
482 #define AVFMT_TS_NEGATIVE 0x40000
491 #define AVFMT_SEEK_TO_PTS 0x4000000
497 typedef struct AVOutputFormat {
498  const char *name;
504  const char *long_name;
505  const char *mime_type;
506  const char *extensions;
507  /* output support */
508  enum AVCodecID audio_codec;
509  enum AVCodecID video_codec;
510  enum AVCodecID subtitle_codec;
517  int flags;
523  const struct AVCodecTag * const *codec_tag;
524 
525 
526  const AVClass *priv_class;
527 
528  /*****************************************************************
529  * No fields below this line are part of the public API. They
530  * may not be used outside of libavformat and can be changed and
531  * removed at will.
532  * New public fields should be added right above.
533  *****************************************************************
534  */
535  struct AVOutputFormat *next;
539  int priv_data_size;
540 
541  int (*write_header)(struct AVFormatContext *);
549  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
550  int (*write_trailer)(struct AVFormatContext *);
554  int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
555  AVPacket *in, int flush);
563  int (*query_codec)(enum AVCodecID id, int std_compliance);
564 
565  void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
566  int64_t *dts, int64_t *wall);
570  int (*control_message)(struct AVFormatContext *s, int type,
571  void *data, size_t data_size);
581  int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
582  AVFrame **frame, unsigned flags);
587  int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
592  int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
597  int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
598  enum AVCodecID data_codec;
608  int (*init)(struct AVFormatContext *);
617  void (*deinit)(struct AVFormatContext *);
623  int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);
633 typedef struct AVInputFormat {
638  const char *name;
639 
645  const char *long_name;
646 
652  int flags;
653 
659  const char *extensions;
660 
661  const struct AVCodecTag * const *codec_tag;
662 
663  const AVClass *priv_class;
664 
670  const char *mime_type;
671 
672  /*****************************************************************
673  * No fields below this line are part of the public API. They
674  * may not be used outside of libavformat and can be changed and
675  * removed at will.
676  * New public fields should be added right above.
677  *****************************************************************
678  */
679  struct AVInputFormat *next;
680 
684  int raw_codec_id;
685 
689  int priv_data_size;
690 
696  int (*read_probe)(AVProbeData *);
697 
703  int (*read_header)(struct AVFormatContext *);
704 
714  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
715 
720  int (*read_close)(struct AVFormatContext *);
721 
730  int (*read_seek)(struct AVFormatContext *,
731  int stream_index, int64_t timestamp, int flags);
732 
737  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
738  int64_t *pos, int64_t pos_limit);
744  int (*read_play)(struct AVFormatContext *);
745 
750  int (*read_pause)(struct AVFormatContext *);
751 
758  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
764  int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
765 
770  int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
771 
776  int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
777 } AVInputFormat;
782 enum AVStreamParseType {
783  AVSTREAM_PARSE_NONE,
791 };
792 
793 typedef struct AVIndexEntry {
794  int64_t pos;
795  int64_t timestamp;
801 #define AVINDEX_KEYFRAME 0x0001
802 #define AVINDEX_DISCARD_FRAME 0x0002
805  int flags:2;
806  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).
807  int min_distance;
808 } AVIndexEntry;
809 
810 #define AV_DISPOSITION_DEFAULT 0x0001
811 #define AV_DISPOSITION_DUB 0x0002
812 #define AV_DISPOSITION_ORIGINAL 0x0004
813 #define AV_DISPOSITION_COMMENT 0x0008
814 #define AV_DISPOSITION_LYRICS 0x0010
815 #define AV_DISPOSITION_KARAOKE 0x0020
822 #define AV_DISPOSITION_FORCED 0x0040
823 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
824 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
825 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
833 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
838 #define AV_DISPOSITION_TIMED_THUMBNAILS 0x0800
839 
840 typedef struct AVStreamInternal AVStreamInternal;
841 
845 #define AV_DISPOSITION_CAPTIONS 0x10000
846 #define AV_DISPOSITION_DESCRIPTIONS 0x20000
847 #define AV_DISPOSITION_METADATA 0x40000
848 #define AV_DISPOSITION_DEPENDENT 0x80000
849 #define AV_DISPOSITION_STILL_IMAGE 0x100000
850 
851 
854 #define AV_PTS_WRAP_IGNORE 0
855 #define AV_PTS_WRAP_ADD_OFFSET 1
856 #define AV_PTS_WRAP_SUB_OFFSET -1
865 typedef struct AVStream {
866  int index;
872  int id;
873 #if FF_API_LAVF_AVCTX
877  attribute_deprecated
878  AVCodecContext *codec;
879 #endif
880  void *priv_data;
894  AVRational time_base;
895 
904  int64_t start_time;
905 
914  int64_t duration;
915 
916  int64_t nb_frames;
917 
918  int disposition;
920  enum AVDiscard discard;
921 
927  AVRational sample_aspect_ratio;
928 
929  AVDictionary *metadata;
930 
938  AVRational avg_frame_rate;
939 
947  AVPacket attached_pic;
948 
967  AVPacketSideData *side_data;
971  int nb_side_data;
972 
978  int event_flags;
979 #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001
981 
989  AVRational r_frame_rate;
990 
991 #if FF_API_LAVF_FFSERVER
992 
999  attribute_deprecated
1000  char *recommended_encoder_configuration;
1001 #endif
1002 
1012  AVCodecParameters *codecpar;
1013 
1014  /*****************************************************************
1015  * All fields below this line are not part of the public API. They
1016  * may not be used outside of libavformat and can be changed and
1017  * removed at will.
1018  * Internal note: be aware that physically removing these fields
1019  * will break ABI. Replace removed fields with dummy fields, and
1020  * add new fields to AVStreamInternal.
1021  *****************************************************************
1022  */
1023 
1024 #define MAX_STD_TIMEBASES (30*12+30+3+6)
1025 
1028  struct {
1029  int64_t last_dts;
1030  int64_t duration_gcd;
1031  int duration_count;
1032  int64_t rfps_duration_sum;
1033  double (*duration_error)[2][MAX_STD_TIMEBASES];
1034  int64_t codec_info_duration;
1035  int64_t codec_info_duration_fields;
1036  int frame_delay_evidence;
1037 
1043  int found_decoder;
1044 
1045  int64_t last_duration;
1046 
1050  int64_t fps_first_dts;
1051  int fps_first_dts_idx;
1052  int64_t fps_last_dts;
1053  int fps_last_dts_idx;
1054 
1055  } *info;
1056 
1057  int pts_wrap_bits;
1059  // Timestamp generation support:
1067  int64_t first_dts;
1068  int64_t cur_dts;
1069  int64_t last_IP_pts;
1070  int last_IP_duration;
1071 
1075  int probe_packets;
1080  int codec_info_nb_frames;
1081 
1082  /* av_read_frame() support */
1083  enum AVStreamParseType need_parsing;
1084  struct AVCodecParserContext *parser;
1085 
1089  struct AVPacketList *last_in_packet_buffer;
1090  AVProbeData probe_data;
1091 #define MAX_REORDER_DELAY 16
1092  int64_t pts_buffer[MAX_REORDER_DELAY+1];
1093 
1094  AVIndexEntry *index_entries;
1096  int nb_index_entries;
1097  unsigned int index_entries_allocated_size;
1104  int stream_identifier;
1105 
1109  int program_num;
1110  int pmt_version;
1111  int pmt_stream_idx;
1112 
1113  int64_t interleaver_chunk_size;
1114  int64_t interleaver_chunk_duration;
1115 
1123  int request_probe;
1128  int skip_to_keyframe;
1129 
1133  int skip_samples;
1134 
1142  int64_t start_skip_samples;
1143 
1150  int64_t first_discard_sample;
1157  int64_t last_discard_sample;
1158 
1163  int nb_decoded_frames;
1164 
1169  int64_t mux_ts_offset;
1170 
1174  int64_t pts_wrap_reference;
1175 
1186  int pts_wrap_behavior;
1187 
1191  int update_initial_durations_done;
1192 
1196  int64_t pts_reorder_error[MAX_REORDER_DELAY+1];
1197  uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1];
1198 
1202  int64_t last_dts_for_order_check;
1203  uint8_t dts_ordered;
1204  uint8_t dts_misordered;
1209  int inject_global_side_data;
1210 
1216  AVRational display_aspect_ratio;
1217 
1222  AVStreamInternal *internal;
1223 } AVStream;
1224 
1225 #if FF_API_FORMAT_GET_SET
1226 
1230 attribute_deprecated
1231 AVRational av_stream_get_r_frame_rate(const AVStream *s);
1232 attribute_deprecated
1233 void av_stream_set_r_frame_rate(AVStream *s, AVRational r);
1234 #if FF_API_LAVF_FFSERVER
1235 attribute_deprecated
1236 char* av_stream_get_recommended_encoder_configuration(const AVStream *s);
1237 attribute_deprecated
1238 void av_stream_set_recommended_encoder_configuration(AVStream *s, char *configuration);
1239 #endif
1240 #endif
1241 
1242 struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
1243 
1249 int64_t av_stream_get_end_pts(const AVStream *st);
1250 
1251 #define AV_PROGRAM_RUNNING 1
1252 
1259 typedef struct AVProgram {
1260  int id;
1261  int flags;
1262  enum AVDiscard discard;
1263  unsigned int *stream_index;
1264  unsigned int nb_stream_indexes;
1265  AVDictionary *metadata;
1266 
1267  int program_num;
1268  int pmt_pid;
1269  int pcr_pid;
1270  int pmt_version;
1272  /*****************************************************************
1273  * All fields below this line are not part of the public API. They
1274  * may not be used outside of libavformat and can be changed and
1275  * removed at will.
1276  * New public fields should be added right above.
1277  *****************************************************************
1278  */
1279  int64_t start_time;
1280  int64_t end_time;
1281 
1282  int64_t pts_wrap_reference;
1283  int pts_wrap_behavior;
1284 } AVProgram;
1285 
1286 #define AVFMTCTX_NOHEADER 0x0001
1288 #define AVFMTCTX_UNSEEKABLE 0x0002
1294 typedef struct AVChapter {
1295  int id;
1296  AVRational time_base;
1297  int64_t start, end;
1298  AVDictionary *metadata;
1299 } AVChapter;
1300 
1301 
1305 typedef int (*av_format_control_message)(struct AVFormatContext *s, int type,
1306  void *data, size_t data_size);
1307 
1308 typedef int (*AVOpenCallback)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
1309  const AVIOInterruptCB *int_cb, AVDictionary **options);
1319 };
1320 
1321 typedef struct AVFormatInternal AVFormatInternal;
1322 
1337 typedef struct AVFormatContext {
1342  const AVClass *av_class;
1343 
1349  struct AVInputFormat *iformat;
1350 
1356  struct AVOutputFormat *oformat;
1357 
1365  void *priv_data;
1366 
1380 
1381  /* stream info */
1386  int ctx_flags;
1387 
1393  unsigned int nb_streams;
1405  AVStream **streams;
1406 
1407 #if FF_API_FORMAT_FILENAME
1408 
1416  attribute_deprecated
1417  char filename[1024];
1418 #endif
1433  char *url;
1434 
1442  int64_t start_time;
1443 
1452  int64_t duration;
1453 
1459  int64_t bit_rate;
1460 
1461  unsigned int packet_size;
1462  int max_delay;
1463 
1468  int flags;
1469 #define AVFMT_FLAG_GENPTS 0x0001
1470 #define AVFMT_FLAG_IGNIDX 0x0002
1471 #define AVFMT_FLAG_NONBLOCK 0x0004
1472 #define AVFMT_FLAG_IGNDTS 0x0008
1473 #define AVFMT_FLAG_NOFILLIN 0x0010
1474 #define AVFMT_FLAG_NOPARSE 0x0020
1475 #define AVFMT_FLAG_NOBUFFER 0x0040
1476 #define AVFMT_FLAG_CUSTOM_IO 0x0080
1477 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100
1478 #define AVFMT_FLAG_FLUSH_PACKETS 0x0200
1479 
1485 #define AVFMT_FLAG_BITEXACT 0x0400
1486 #if FF_API_LAVF_MP4A_LATM
1487 #define AVFMT_FLAG_MP4A_LATM 0x8000
1488 #endif
1489 #define AVFMT_FLAG_SORT_DTS 0x10000
1490 #define AVFMT_FLAG_PRIV_OPT 0x20000
1491 #if FF_API_LAVF_KEEPSIDE_FLAG
1492 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000
1493 #endif
1494 #define AVFMT_FLAG_FAST_SEEK 0x80000
1495 #define AVFMT_FLAG_SHORTEST 0x100000
1496 #define AVFMT_FLAG_AUTO_BSF 0x200000
1497 
1498 
1503  int64_t probesize;
1511  int64_t max_analyze_duration;
1512 
1513  const uint8_t *key;
1514  int keylen;
1515 
1516  unsigned int nb_programs;
1517  AVProgram **programs;
1518 
1523  enum AVCodecID video_codec_id;
1524 
1529  enum AVCodecID audio_codec_id;
1530 
1535  enum AVCodecID subtitle_codec_id;
1536 
1547  unsigned int max_index_size;
1548 
1553  unsigned int max_picture_buffer;
1554 
1566  unsigned int nb_chapters;
1567  AVChapter **chapters;
1568 
1577  AVDictionary *metadata;
1578 
1590  int64_t start_time_realtime;
1597  int fps_probe_size;
1598 
1604  int error_recognition;
1605 
1615  AVIOInterruptCB interrupt_callback;
1616 
1620  int debug;
1621 #define FF_FDEBUG_TS 0x0001
1622 
1639  int64_t max_interleave_delta;
1640 
1645  int strict_std_compliance;
1646 
1652  int event_flags;
1653 #define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001
1654 
1655 
1659  int max_ts_probe;
1660 
1668  int avoid_negative_ts;
1669 #define AVFMT_AVOID_NEG_TS_AUTO -1
1670 #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1
1671 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2
1672 
1677  int ts_id;
1678 
1685  int audio_preload;
1686 
1693  int max_chunk_duration;
1694 
1701  int max_chunk_size;
1702 
1709  int use_wallclock_as_timestamps;
1710 
1716  int avio_flags;
1717 
1724  enum AVDurationEstimationMethod duration_estimation_method;
1725 
1731  int64_t skip_initial_bytes;
1732 
1738  unsigned int correct_ts_overflow;
1739 
1745  int seek2any;
1746 
1752  int flush_packets;
1753 
1761  int probe_score;
1762 
1768  int format_probesize;
1769 
1776  char *codec_whitelist;
1777 
1784  char *format_whitelist;
1785 
1790  AVFormatInternal *internal;
1791 
1798  int io_repositioned;
1799 
1807 
1815 
1823 
1831 
1837  int metadata_header_padding;
1838 
1843  void *opaque;
1848  av_format_control_message control_message_cb;
1849 
1854  int64_t output_ts_offset;
1855 
1862  uint8_t *dump_separator;
1863 
1868  enum AVCodecID data_codec_id;
1869 
1870 #if FF_API_OLD_OPEN_CALLBACKS
1871 
1888  attribute_deprecated
1889  int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options);
1890 #endif
1891 
1897  char *protocol_whitelist;
1898 
1919  int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,
1920  int flags, AVDictionary **options);
1921 
1925  void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
1926 
1932  char *protocol_blacklist;
1940 
1947 } AVFormatContext;
1948 
1949 #if FF_API_FORMAT_GET_SET
1950 
1954 attribute_deprecated
1955 int av_format_get_probe_score(const AVFormatContext *s);
1956 attribute_deprecated
1957 AVCodec * av_format_get_video_codec(const AVFormatContext *s);
1958 attribute_deprecated
1959 void av_format_set_video_codec(AVFormatContext *s, AVCodec *c);
1960 attribute_deprecated
1961 AVCodec * av_format_get_audio_codec(const AVFormatContext *s);
1962 attribute_deprecated
1963 void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c);
1964 attribute_deprecated
1965 AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s);
1966 attribute_deprecated
1967 void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c);
1968 attribute_deprecated
1969 AVCodec * av_format_get_data_codec(const AVFormatContext *s);
1970 attribute_deprecated
1971 void av_format_set_data_codec(AVFormatContext *s, AVCodec *c);
1972 attribute_deprecated
1973 int av_format_get_metadata_header_padding(const AVFormatContext *s);
1974 attribute_deprecated
1975 void av_format_set_metadata_header_padding(AVFormatContext *s, int c);
1976 attribute_deprecated
1977 void * av_format_get_opaque(const AVFormatContext *s);
1978 attribute_deprecated
1979 void av_format_set_opaque(AVFormatContext *s, void *opaque);
1980 attribute_deprecated
1981 av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s);
1982 attribute_deprecated
1983 void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback);
1984 #if FF_API_OLD_OPEN_CALLBACKS
1985 attribute_deprecated AVOpenCallback av_format_get_open_cb(const AVFormatContext *s);
1986 attribute_deprecated void av_format_set_open_cb(AVFormatContext *s, AVOpenCallback callback);
1987 #endif
1988 #endif
1989 
1995 
2002 
2003 typedef struct AVPacketList {
2004  AVPacket pkt;
2005  struct AVPacketList *next;
2006 } AVPacketList;
2007 
2008 
2021 unsigned avformat_version(void);
2022 
2026 const char *avformat_configuration(void);
2027 
2031 const char *avformat_license(void);
2032 
2033 #if FF_API_NEXT
2034 
2042 attribute_deprecated
2043 void av_register_all(void);
2044 
2045 attribute_deprecated
2046 void av_register_input_format(AVInputFormat *format);
2047 attribute_deprecated
2048 void av_register_output_format(AVOutputFormat *format);
2049 #endif
2050 
2065 int avformat_network_init(void);
2066 
2071 int avformat_network_deinit(void);
2072 
2073 #if FF_API_NEXT
2074 
2079 attribute_deprecated
2080 AVInputFormat *av_iformat_next(const AVInputFormat *f);
2081 
2087 attribute_deprecated
2088 AVOutputFormat *av_oformat_next(const AVOutputFormat *f);
2089 #endif
2090 
2100 const AVOutputFormat *av_muxer_iterate(void **opaque);
2101 
2111 const AVInputFormat *av_demuxer_iterate(void **opaque);
2112 
2119 
2125 
2132 const AVClass *avformat_get_class(void);
2133 
2154 
2168  uint8_t *data, size_t size);
2169 
2178 uint8_t *av_stream_new_side_data(AVStream *stream,
2179  enum AVPacketSideDataType type, int size);
2188 uint8_t *av_stream_get_side_data(const AVStream *stream,
2189  enum AVPacketSideDataType type, int *size);
2190 
2191 AVProgram *av_new_program(AVFormatContext *s, int id);
2192 
2215  const char *format_name, const char *filename);
2216 
2225 AVInputFormat *av_find_input_format(const char *short_name);
2226 
2234 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
2235 
2248 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
2249 
2257 AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret);
2258 
2276  const char *url, void *logctx,
2277  unsigned int offset, unsigned int max_probe_size);
2278 
2283  const char *url, void *logctx,
2284  unsigned int offset, unsigned int max_probe_size);
2285 
2305 int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options);
2306 
2307 attribute_deprecated
2308 int av_demuxer_open(AVFormatContext *ic);
2309 
2332 
2344 
2345 void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx);
2346 
2372  enum AVMediaType type,
2373  int wanted_stream_nb,
2374  int related_stream,
2375  AVCodec **decoder_ret,
2376  int flags);
2377 
2402 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
2403 
2417 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
2418  int flags);
2419 
2448 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
2449 
2467 
2473 
2480 
2490 #define AVSEEK_FLAG_BACKWARD 1
2491 #define AVSEEK_FLAG_BYTE 2
2492 #define AVSEEK_FLAG_ANY 4
2493 #define AVSEEK_FLAG_FRAME 8
2494 
2495 
2500 #define AVSTREAM_INIT_IN_WRITE_HEADER 0
2501 #define AVSTREAM_INIT_IN_INIT_OUTPUT 1
2502 
2503 
2520 av_warn_unused_result
2522 
2542 av_warn_unused_result
2544 
2583 
2628 
2637 int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
2638  AVFrame *frame);
2639 
2656 int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index,
2657  AVFrame *frame);
2658 
2665 int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index);
2666 
2677 
2690 AVOutputFormat *av_guess_format(const char *short_name,
2691  const char *filename,
2692  const char *mime_type);
2693 
2697 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
2698  const char *filename, const char *mime_type,
2699  enum AVMediaType type);
2700 
2716 int av_get_output_timestamp(struct AVFormatContext *s, int stream,
2717  int64_t *dts, int64_t *wall);
2718 
2719 
2743 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
2744 
2757 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
2758 
2767 void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st);
2768 
2769 
2781 void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
2782  const AVStream *st);
2783 
2792 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
2793 
2802 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
2803 
2813 int av_codec_get_tag2(const struct AVCodecTag * const *tags, enum AVCodecID id,
2814  unsigned int *tag);
2815 
2816 int av_find_default_stream_index(AVFormatContext *s);
2817 
2829 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
2830 
2837 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
2838  int size, int distance, int flags);
2839 
2840 
2860 void av_url_split(char *proto, int proto_size,
2861  char *authorization, int authorization_size,
2862  char *hostname, int hostname_size,
2863  int *port_ptr,
2864  char *path, int path_size,
2865  const char *url);
2866 
2867 
2879  int index,
2880  const char *url,
2881  int is_output);
2882 
2883 
2884 #define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1
2885 
2886 
2899 int av_get_frame_filename2(char *buf, int buf_size,
2900  const char *path, int number, int flags);
2901 
2902 int av_get_frame_filename(char *buf, int buf_size,
2903  const char *path, int number);
2904 
2911 int av_filename_number_test(const char *filename);
2912 
2930 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
2931 
2939 int av_match_ext(const char *filename, const char *extensions);
2940 
2951 int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
2952  int std_compliance);
2953 
2969 const struct AVCodecTag *avformat_get_riff_video_tags(void);
2973 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
2977 const struct AVCodecTag *avformat_get_mov_video_tags(void);
2981 const struct AVCodecTag *avformat_get_mov_audio_tags(void);
2982 
3005 
3015 
3030  const char *spec);
3031 
3032 int avformat_queue_attached_pictures(AVFormatContext *s);
3033 
3034 #if FF_API_OLD_BSF
3035 
3046 attribute_deprecated
3047 int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
3048  AVBitStreamFilterContext *bsfc);
3049 #endif
3050 
3051 enum AVTimebaseSource {
3052  AVFMT_TBCF_AUTO = -1,
3053  AVFMT_TBCF_DECODER,
3054  AVFMT_TBCF_DEMUXER,
3055 #if FF_API_R_FRAME_RATE
3056  AVFMT_TBCF_R_FRAMERATE,
3057 #endif
3058 };
3059 
3071  AVStream *ost, const AVStream *ist,
3072  enum AVTimebaseSource copy_tb);
3073 
3080 
3085 #endif /* AVFORMAT_AVFORMAT_H */
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
Definition: utils.c:4728
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
Definition: avformat.h:1933
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:795
Bytestream IO Context.
Definition: avio.h:161
void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
Send a nice dump of a packet to the specified file stream.
Definition: dump.c:108
Buffered I/O operations.
AVPacketSideDataType
Definition: avcodec.h:1175
struct AVProgram AVProgram
New fields can be added to the end with minor version bumps.
This structure describes decoded (raw) audio or video data.
Definition: frame.h:268
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: mux.c:1185
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
Definition: utils.c:2039
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: mux.c:878
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio...
Definition: utils.c:5056
enum AVCodecID video_codec
default video codec
Definition: avformat.h:518
int av_get_output_timestamp(struct AVFormatContext *s, int stream, int64_t *dts, int64_t *wall)
Get timing information for the data currently output.
Definition: mux.c:1302
AVInputFormat * av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
Definition: format.c:128
Definition: avformat.h:642
int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index)
Test whether a muxer supports uncoded frame.
Definition: mux.c:1379
int priv_data_size
Size of private data so that it can be allocated in the wrapper.
Definition: avformat.h:698
AVCodec.
Definition: avcodec.h:3468
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3936
enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext *ctx)
Returns the method used to set ctx->duration.
Definition: options.c:163
Format I/O context.
Definition: avformat.h:1351
AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
Definition: utils.c:5079
const struct AVCodecTag * avformat_get_mov_audio_tags(void)
Definition: isom.c:662
Public dictionary API.
int flags
can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
Definition: avformat.h:526
struct AVStream AVStream
Stream structure.
const struct AVCodecTag * avformat_get_riff_video_tags(void)
Definition: riff.c:584
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
unsigned avformat_version(void)
Return the LIBAVFORMAT_VERSION_INT constant.
Definition: utils.c:66
const char * avformat_license(void)
Return the libavformat license.
Definition: utils.c:77
int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt, AVStream *ost, const AVStream *ist, enum AVTimebaseSource copy_tb)
Transfer internal timing information from one stream to another.
Definition: utils.c:5717
int priv_data_size
size of private data so that it can be allocated in the wrapper
Definition: avformat.h:548
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
Definition: utils.c:5261
AVDurationEstimationMethod
The duration of a video can be estimated through various ways, and this enum can be used to know how ...
Definition: avformat.h:1329
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4455
uint8_t * av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
Definition: utils.c:5437
int av_codec_get_tag2(const struct AVCodecTag *const *tags, enum AVCodecID id, unsigned int *tag)
Get the codec tag for the given codec id.
Definition: internal.h:44
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:144
void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, const AVStream *st)
Send a nice dump of a packet to the log.
Definition: dump.c:113
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
Definition: utils.c:72
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1482
Definition: avformat.h:2017
char * protocol_whitelist
&#39;,&#39; separated list of allowed protocols.
Definition: avformat.h:1911
int avformat_network_init(void)
Do global initialization of network libraries.
Definition: utils.c:4993
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
Definition: riff.c:589
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
Definition: sdp.c:841
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:310
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
Definition: format.c:38
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:168
int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
Definition: format.c:222
full parsing and repack with timestamp and position generation by parser for raw this assumes that ea...
Definition: avformat.h:797
Duration estimated from bitrate (less accurate)
Definition: avformat.h:1332
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
Read data and append it to the current content of the AVPacket.
Definition: utils.c:320
const AVOutputFormat * av_muxer_iterate(void **opaque)
Iterate over all registered muxers.
Definition: allformats.c:503
const struct AVCodecTag * avformat_get_mov_video_tags(void)
Definition: isom.c:657
int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, const char *format_name, const char *filename)
Allocate an AVFormatContext for an output format.
Definition: mux.c:148
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Definition: dump.c:563
Callback for checking whether to abort blocking functions.
Definition: avio.h:58
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
Find the "best" stream in the file.
Definition: utils.c:4183
AVRational av_stream_get_codec_timebase(const AVStream *st)
Get the internal codec timebase from a stream.
Definition: utils.c:5779
int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Like av_probe_input_buffer2() but returns 0 on success.
Definition: format.c:312
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
Definition: utils.c:4166
Definition: dict.c:30
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:215
Definition: internal.h:149
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:2148
void av_hex_dump(FILE *f, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the specified file stream.
Definition: dump.c:74
char * url
input or output URL.
Definition: avformat.h:1447
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
Definition: utils.c:4250
struct AVFormatContext AVFormatContext
Format I/O context.
int skip_estimate_duration_from_pts
Skip duration calcuation in estimate_timings_from_pts.
Definition: avformat.h:1960
New fields can be added to the end with minor version bumps.
Definition: avformat.h:1268
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
Definition: format.c:205
void * opaque
User data.
Definition: avformat.h:1857
Only parse headers, do not repack.
Definition: avformat.h:794
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
Definition: utils.c:4975
Definition: internal.h:66
const char * mime_type
mime_type, when known.
Definition: avformat.h:452
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:451
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:450
void av_format_inject_global_side_data(AVFormatContext *s)
This function will cause global side data to be injected in the next packet of each stream as well as...
Definition: utils.c:154
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
Definition: utils.c:4259
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:118
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
Definition: mux.c:508
int(* av_format_control_message)(struct AVFormatContext *s, int type, void *data, size_t data_size)
Callback used by devices to communicate with application.
Definition: avformat.h:1319
int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as stream side data.
Definition: utils.c:5452
enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type)
Guess the codec ID based upon muxer and filename.
Definition: format.c:87
int max_streams
The maximum number of streams.
Definition: avformat.h:1953
Definition: avformat.h:802
Duration estimated from a stream with a known duration.
Definition: avformat.h:1331
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
Definition: utils.c:5488
AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
Definition: format.c:51
Libavformat version macros.
av_warn_unused_result int avformat_init_output(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and initialize the codec, but do not write the header.
Definition: mux.c:488
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
Definition: allformats.c:520
Definition: avcodec.h:5092
Definition: avcodec.h:5722
Stream structure.
Definition: avformat.h:874
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:5005
Definition: avcodec.h:1411
Libavcodec external API header.
AVIOContext * pb
I/O context.
Definition: avformat.h:1393
main external API structure.
Definition: avcodec.h:1556
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:327
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
Return in &#39;buf&#39; the path with &#39;d&#39; replaced by a number.
Definition: utils.c:4668
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
Definition: avformat.h:1939
Describe the class of an AVClass context structure.
Definition: log.h:67
enum AVCodecID subtitle_codec
default subtitle codec
Definition: avformat.h:519
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVMediaType
Definition: avutil.h:199
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:4389
This structure contains the data a format has to probe a file.
Definition: avformat.h:448
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:1768
List of devices.
Definition: avdevice.h:460
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
Definition: utils.c:2529
full parsing and repack of the first frame only, only implemented for H.264 currently ...
Definition: avformat.h:796
int raw_codec_id
Raw demuxers store their codec ID here.
Definition: avformat.h:693
Duration accurately estimated from PTSes.
Definition: avformat.h:1330
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
Definition: utils.c:2506
full parsing and repack
Definition: avformat.h:793
Definition: avformat.h:1308
int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write an uncoded frame to an output media file.
Definition: mux.c:1373
enum AVCodecID data_codec
default data codec
Definition: avformat.h:607
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:3564
AVStreamParseType
Definition: avformat.h:791
struct AVProbeData AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:506
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:4427
int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write an uncoded frame to an output media file.
Definition: mux.c:1367
int(* read_header)(struct AVFormatContext *)
Read the format header and initialize the AVFormatContext structure.
Definition: avformat.h:712
enum AVCodecID audio_codec
default audio codec
Definition: avformat.h:517
int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:537
AVDiscard
Definition: avcodec.h:798
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: mux.c:1247
char * protocol_blacklist
&#39;,&#39; separated list of disallowed protocols.
Definition: avformat.h:1946
int avformat_flush(AVFormatContext *s)
Discard all internally buffered data.
Definition: utils.c:2586
int(* read_probe)(AVProbeData *)
Tell if a given file has a chance of being parsed as this format.
Definition: avformat.h:705
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
Definition: dump.c:79
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
Definition: format.c:216
Following API allows user to probe device capabilities (supported codecs, pixel formats, sample formats, resolutions, channel counts, etc).
Definition: avdevice.h:400
This structure stores compressed data.
Definition: avcodec.h:1445
int64_t av_stream_get_end_pts(const AVStream *st)
Returns the pts of the last muxed packet + its duration.
Definition: utils.c:141