avformat.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of Libav.
5  *
6  * Libav 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  * Libav 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 Libav; 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 
138 #include <time.h>
139 #include <stdio.h> /* FILE */
140 #include "libavcodec/avcodec.h"
141 #include "libavutil/dict.h"
142 #include "libavutil/log.h"
143 
144 #include "avio.h"
145 #include "libavformat/version.h"
146 
147 struct AVFormatContext;
148 
149 
223 #if FF_API_OLD_METADATA2
224 
231 #define AV_METADATA_MATCH_CASE AV_DICT_MATCH_CASE
232 #define AV_METADATA_IGNORE_SUFFIX AV_DICT_IGNORE_SUFFIX
233 #define AV_METADATA_DONT_STRDUP_KEY AV_DICT_DONT_STRDUP_KEY
234 #define AV_METADATA_DONT_STRDUP_VAL AV_DICT_DONT_STRDUP_VAL
235 #define AV_METADATA_DONT_OVERWRITE AV_DICT_DONT_OVERWRITE
236 
237 typedef attribute_deprecated AVDictionary AVMetadata;
238 typedef attribute_deprecated AVDictionaryEntry AVMetadataTag;
239 
240 typedef struct AVMetadataConv AVMetadataConv;
241 
251 av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
252 
263 attribute_deprecated int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags);
264 
268 attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
269  const AVMetadataConv *s_conv);
270 
279 attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags);
280 
284 attribute_deprecated void av_metadata_free(AVDictionary **m);
288 #endif
289 
290 
291 /* packet functions */
292 
293 
302 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
303 
304 
318 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
319 
320 /*************************************************/
321 /* fractional numbers for exact pts handling */
322 
327 typedef struct AVFrac {
328  int64_t val, num, den;
329 } AVFrac;
330 
331 /*************************************************/
332 /* input/output formats */
333 
334 struct AVCodecTag;
335 
339 typedef struct AVProbeData {
340  const char *filename;
341  unsigned char *buf;
342  int buf_size;
343 } AVProbeData;
344 
345 #define AVPROBE_SCORE_MAX 100
346 #define AVPROBE_PADDING_SIZE 32
347 
348 typedef struct AVFormatParameters {
349 #if FF_API_FORMAT_PARAMETERS
351  attribute_deprecated int sample_rate;
352  attribute_deprecated int channels;
356  attribute_deprecated int channel;
357  attribute_deprecated const char *standard;
358  attribute_deprecated unsigned int mpeg2ts_raw:1;
360  attribute_deprecated unsigned int mpeg2ts_compute_pcr:1;
361  attribute_deprecated unsigned int initial_pause:1;
363  attribute_deprecated unsigned int prealloced_context:1;
364 #endif
366 
368 #define AVFMT_NOFILE 0x0001
369 #define AVFMT_NEEDNUMBER 0x0002
370 #define AVFMT_SHOW_IDS 0x0008
371 #define AVFMT_RAWPICTURE 0x0020
373 #define AVFMT_GLOBALHEADER 0x0040
374 #define AVFMT_NOTIMESTAMPS 0x0080
375 #define AVFMT_GENERIC_INDEX 0x0100
376 #define AVFMT_TS_DISCONT 0x0200
377 #define AVFMT_VARIABLE_FPS 0x0400
378 #define AVFMT_NODIMENSIONS 0x0800
379 #define AVFMT_NOSTREAMS 0x1000
380 #define AVFMT_NOBINSEARCH 0x2000
381 #define AVFMT_NOGENSEARCH 0x4000
382 #define AVFMT_NO_BYTE_SEEK 0x8000
388 typedef struct AVOutputFormat {
389  const char *name;
395  const char *long_name;
396  const char *mime_type;
397  const char *extensions;
401  int priv_data_size;
402  /* output support */
403  enum CodecID audio_codec;
404  enum CodecID video_codec;
405  int (*write_header)(struct AVFormatContext *);
406  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
407  int (*write_trailer)(struct AVFormatContext *);
413  int flags;
417  int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
419  AVPacket *in, int flush);
420 
425  const struct AVCodecTag * const *codec_tag;
427  enum CodecID subtitle_codec;
429 #if FF_API_OLD_METADATA2
430  const AVMetadataConv *metadata_conv;
431 #endif
432 
433  const AVClass *priv_class;
441  int (*query_codec)(enum CodecID id, int std_compliance);
443  /* private fields */
444  struct AVOutputFormat *next;
454 typedef struct AVInputFormat {
459  const char *name;
466  const char *long_name;
471  int priv_data_size;
478  int (*read_probe)(AVProbeData *);
486  int (*read_header)(struct AVFormatContext *,
488 
498  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
504  int (*read_close)(struct AVFormatContext *);
514  int (*read_seek)(struct AVFormatContext *,
515  int stream_index, int64_t timestamp, int flags);
516 
521  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
522  int64_t *pos, int64_t pos_limit);
523 
529  int flags;
536  const char *extensions;
541  int value;
547  int (*read_play)(struct AVFormatContext *);
553  int (*read_pause)(struct AVFormatContext *);
555  const struct AVCodecTag * const *codec_tag;
563  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
565 #if FF_API_OLD_METADATA2
566  const AVMetadataConv *metadata_conv;
567 #endif
568 
569  const AVClass *priv_class;
571  /* private fields */
572  struct AVInputFormat *next;
578 enum AVStreamParseType {
584 };
585 
586 typedef struct AVIndexEntry {
587  int64_t pos;
588  int64_t timestamp;
589 #define AVINDEX_KEYFRAME 0x0001
590  int flags:2;
591  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).
594 
595 #define AV_DISPOSITION_DEFAULT 0x0001
596 #define AV_DISPOSITION_DUB 0x0002
597 #define AV_DISPOSITION_ORIGINAL 0x0004
598 #define AV_DISPOSITION_COMMENT 0x0008
599 #define AV_DISPOSITION_LYRICS 0x0010
600 #define AV_DISPOSITION_KARAOKE 0x0020
607 #define AV_DISPOSITION_FORCED 0x0040
608 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
609 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
610 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
619 typedef struct AVStream {
620  int index;
621  int id;
622  AVCodecContext *codec;
631  AVRational r_frame_rate;
632  void *priv_data;
634 #if FF_API_REORDER_PRIVATE
635  /* internal data used in av_find_stream_info() */
636  int64_t first_dts;
637 #endif
638 
642  struct AVFrac pts;
651  AVRational time_base;
652 #if FF_API_REORDER_PRIVATE
653  int pts_wrap_bits;
654 #endif
655 #if FF_API_STREAM_COPY
656  /* ffmpeg.c private use */
657  attribute_deprecated int stream_copy;
658 #endif
659  enum AVDiscard discard;
661 #if FF_API_AVSTREAM_QUALITY
662  //FIXME move stuff to a flags field?
667  attribute_deprecated float quality;
668 #endif
669 
676  int64_t start_time;
683  int64_t duration;
685 #if FF_API_REORDER_PRIVATE
686  /* av_read_frame() support */
687  enum AVStreamParseType need_parsing;
689 
690  int64_t cur_dts;
691  int last_IP_duration;
692  int64_t last_IP_pts;
693  /* av_seek_frame() support */
694  AVIndexEntry *index_entries;
696  int nb_index_entries;
697  unsigned int index_entries_allocated_size;
698 #endif
699 
700  int64_t nb_frames;
702  int disposition;
704 #if FF_API_REORDER_PRIVATE
705  AVProbeData probe_data;
706 #define MAX_REORDER_DELAY 16
707  int64_t pts_buffer[MAX_REORDER_DELAY+1];
708 #endif
709 
715  AVRational sample_aspect_ratio;
719 #if FF_API_REORDER_PRIVATE
720  /* Intended mostly for av_read_frame() support. Not supposed to be used by */
721  /* external applications; try to use something else if at all possible. */
722  const uint8_t *cur_ptr;
723  int cur_len;
724  AVPacket cur_pkt;
725 
726  // Timestamp generation support:
734  int64_t reference_dts;
735 
740 #define MAX_PROBE_PACKETS 2500
741  int probe_packets;
742 
748  struct AVPacketList *last_in_packet_buffer;
749 #endif
750 
754  AVRational avg_frame_rate;
756  /*****************************************************************
757  * All fields below this line are not part of the public API. They
758  * may not be used outside of libavformat and can be changed and
759  * removed at will.
760  * New public fields should be added right above.
761  *****************************************************************
762  */
763 
767  int codec_info_nb_frames;
772 #define MAX_STD_TIMEBASES (60*12+5)
773  struct {
774  int64_t last_dts;
775  int64_t duration_gcd;
776  int duration_count;
777  double duration_error[MAX_STD_TIMEBASES];
778  int64_t codec_info_duration;
779  int nb_decoded_frames;
780  } *info;
781 #if !FF_API_REORDER_PRIVATE
782  const uint8_t *cur_ptr;
783  int cur_len;
784  AVPacket cur_pkt;
786  // Timestamp generation support:
794  int64_t reference_dts;
795  int64_t first_dts;
796  int64_t cur_dts;
797  int last_IP_duration;
798  int64_t last_IP_pts;
803 #define MAX_PROBE_PACKETS 2500
804  int probe_packets;
809  struct AVPacketList *last_in_packet_buffer;
810  AVProbeData probe_data;
811 #define MAX_REORDER_DELAY 16
812  int64_t pts_buffer[MAX_REORDER_DELAY+1];
813  /* av_read_frame() support */
814  enum AVStreamParseType need_parsing;
817  AVIndexEntry *index_entries;
819  int nb_index_entries;
820  unsigned int index_entries_allocated_size;
822  int pts_wrap_bits;
823 #endif
824 } AVStream;
825 
826 #define AV_PROGRAM_RUNNING 1
834 typedef struct AVProgram {
835  int id;
836  int flags;
838  unsigned int *stream_index;
839  unsigned int nb_stream_indexes;
842 
843 #define AVFMTCTX_NOHEADER 0x0001
846 typedef struct AVChapter {
847  int id;
848  AVRational time_base;
849  int64_t start, end;
861 typedef struct AVFormatContext {
866  const AVClass *av_class;
867 
874  struct AVInputFormat *iformat;
875  struct AVOutputFormat *oformat;
881  void *priv_data;
882 
883  /*
884  * I/O context.
885  *
886  * decoding: either set by the user before avformat_open_input() (then
887  * the user must close it manually) or set by avformat_open_input().
888  * encoding: set by the user.
889  *
890  * Do NOT set this field if AVFMT_NOFILE flag is set in
891  * iformat/oformat.flags. In such a case, the (de)muxer will handle
892  * I/O in some other way and this field will be NULL.
893  */
894  AVIOContext *pb;
895 
905  unsigned int nb_streams;
906  AVStream **streams;
908  char filename[1024];
909  /* stream info */
910 #if FF_API_TIMESTAMP
911 
914  attribute_deprecated int64_t timestamp;
915 #endif
916 
917  int ctx_flags;
918 #if FF_API_REORDER_PRIVATE
919  /* private data for pts handling (do not modify directly). */
925  struct AVPacketList *packet_buffer;
926 #endif
927 
933  int64_t start_time;
934 
941  int64_t duration;
942 
943 #if FF_API_FILESIZE
944 
947  attribute_deprecated int64_t file_size;
948 #endif
949 
955  int bit_rate;
956 
957 #if FF_API_REORDER_PRIVATE
958  /* av_read_frame() support */
959  AVStream *cur_st;
960 
961  /* av_seek_frame() support */
962  int64_t data_offset;
963 #endif
964 
965 #if FF_API_MUXRATE
966 
969  attribute_deprecated int mux_rate;
970 #endif
971  unsigned int packet_size;
972 #if FF_API_PRELOAD
973  attribute_deprecated int preload;
974 #endif
975  int max_delay;
976 
977 #if FF_API_LOOP_OUTPUT
978 #define AVFMT_NOOUTPUTLOOP -1
979 #define AVFMT_INFINITEOUTPUTLOOP 0
980 
986 #endif
987 
988  int flags;
989 #define AVFMT_FLAG_GENPTS 0x0001
990 #define AVFMT_FLAG_IGNIDX 0x0002
991 #define AVFMT_FLAG_NONBLOCK 0x0004
992 #define AVFMT_FLAG_IGNDTS 0x0008
993 #define AVFMT_FLAG_NOFILLIN 0x0010
994 #define AVFMT_FLAG_NOPARSE 0x0020
995 #if FF_API_FLAG_RTP_HINT
996 #define AVFMT_FLAG_RTP_HINT 0x0040
997 #endif
998 #define AVFMT_FLAG_CUSTOM_IO 0x0080
999 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100
1001 #if FF_API_LOOP_INPUT
1002 
1006 #endif
1007 
1011  unsigned int probesize;
1012 
1018 
1019  const uint8_t *key;
1020  int keylen;
1022  unsigned int nb_programs;
1023  AVProgram **programs;
1029  enum CodecID video_codec_id;
1030 
1035  enum CodecID audio_codec_id;
1036 
1042 
1053  unsigned int max_index_size;
1054 
1059  unsigned int max_picture_buffer;
1060 
1061  unsigned int nb_chapters;
1062  AVChapter **chapters;
1067  int debug;
1068 #define FF_FDEBUG_TS 0x0001
1070 #if FF_API_REORDER_PRIVATE
1071 
1079 
1081 #endif
1082 
1084 
1085 #if FF_API_REORDER_PRIVATE
1086 
1090 #define RAW_PACKET_BUFFER_SIZE 2500000
1092 #endif
1093 
1101  int64_t start_time_realtime;
1102 
1106  int fps_probe_size;
1107 
1114  int error_recognition;
1115 
1126 
1127  /*****************************************************************
1128  * All fields below this line are not part of the public API. They
1129  * may not be used outside of libavformat and can be changed and
1130  * removed at will.
1131  * New public fields should be added right above.
1132  *****************************************************************
1133  */
1134 #if !FF_API_REORDER_PRIVATE
1135 
1146 #define RAW_PACKET_BUFFER_SIZE 2500000
1154  struct AVPacketList *packet_buffer;
1157  /* av_read_frame() support */
1158  AVStream *cur_st;
1159 
1160  /* av_seek_frame() support */
1161  int64_t data_offset;
1162 #endif
1164 
1165 typedef struct AVPacketList {
1166  AVPacket pkt;
1170 
1183 unsigned avformat_version(void);
1184 
1188 const char *avformat_configuration(void);
1189 
1193 const char *avformat_license(void);
1194 
1204 void av_register_all(void);
1205 
1208 
1217 int avformat_network_init(void);
1218 
1222 int avformat_network_deinit(void);
1223 
1230 
1237 
1244 
1250 
1257 const AVClass *avformat_get_class(void);
1258 
1275 
1277 
1283 #if FF_API_GUESS_IMG2_CODEC
1284 attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename);
1285 #endif
1286 
1287 #if FF_API_PKT_DUMP
1288 attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
1289 attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
1290  int dump_payload);
1291 #endif
1292 
1293 
1302 AVInputFormat *av_find_input_format(const char *short_name);
1303 
1310 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
1311 
1323 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
1324 
1341  const char *filename, void *logctx,
1342  unsigned int offset, unsigned int max_probe_size);
1343 
1344 #if FF_API_FORMAT_PARAMETERS
1345 
1350 attribute_deprecated int av_open_input_stream(AVFormatContext **ic_ptr,
1351  AVIOContext *pb, const char *filename,
1352  AVInputFormat *fmt, AVFormatParameters *ap);
1353 
1368 attribute_deprecated int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
1369  AVInputFormat *fmt,
1370  int buf_size,
1371  AVFormatParameters *ap);
1372 #endif
1373 
1393 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
1394 
1395 #if FF_API_FORMAT_PARAMETERS
1396 
1412 int av_find_stream_info(AVFormatContext *ic);
1413 #endif
1414 
1437 
1463  enum AVMediaType type,
1464  int wanted_stream_nb,
1465  int related_stream,
1466  AVCodec **decoder_ret,
1467  int flags);
1468 
1480 
1506 
1518 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
1519  int flags);
1520 
1547 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
1548 
1554 
1561 
1562 #if FF_API_FORMAT_PARAMETERS
1563 
1569 void av_close_input_stream(AVFormatContext *s);
1570 #endif
1571 
1572 #if FF_API_CLOSE_INPUT_FILE
1573 
1580 void av_close_input_file(AVFormatContext *s);
1581 #endif
1582 
1592 #if FF_API_NEW_STREAM
1593 
1604 AVStream *av_new_stream(AVFormatContext *s, int id);
1605 #endif
1606 
1607 #if FF_API_SET_PTS_INFO
1608 
1612 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
1613  unsigned int pts_num, unsigned int pts_den);
1614 #endif
1615 
1616 #define AVSEEK_FLAG_BACKWARD 1
1617 #define AVSEEK_FLAG_BYTE 2
1618 #define AVSEEK_FLAG_ANY 4
1619 #define AVSEEK_FLAG_FRAME 8
1621 #if FF_API_SEEK_PUBLIC
1623 int av_seek_frame_binary(AVFormatContext *s, int stream_index,
1624  int64_t target_ts, int flags);
1626 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
1628 int64_t av_gen_search(AVFormatContext *s, int stream_index,
1629  int64_t target_ts, int64_t pos_min,
1630  int64_t pos_max, int64_t pos_limit,
1631  int64_t ts_min, int64_t ts_max,
1632  int flags, int64_t *ts_ret,
1633  int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
1634 #endif
1635 
1636 #if FF_API_FORMAT_PARAMETERS
1637 
1640 attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1641 #endif
1642 
1663 
1664 #if FF_API_FORMAT_PARAMETERS
1665 
1676 attribute_deprecated int av_write_header(AVFormatContext *s);
1677 #endif
1678 
1692 
1718 
1735  AVPacket *pkt, int flush);
1736 
1747 
1760 AVOutputFormat *av_guess_format(const char *short_name,
1761  const char *filename,
1762  const char *mime_type);
1763 
1767 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
1768  const char *filename, const char *mime_type,
1769  enum AVMediaType type);
1770 
1794 void av_hex_dump(FILE *f, uint8_t *buf, int size);
1795 
1808 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
1809 
1818 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
1819 
1820 
1832 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1833  AVStream *st);
1834 
1842 enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
1843 
1851 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
1852 
1854 
1863 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1864 
1871 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1872  int size, int distance, int flags);
1873 
1874 
1894 void av_url_split(char *proto, int proto_size,
1895  char *authorization, int authorization_size,
1896  char *hostname, int hostname_size,
1897  int *port_ptr,
1898  char *path, int path_size,
1899  const char *url);
1900 
1901 #if FF_API_DUMP_FORMAT
1902 attribute_deprecated void dump_format(AVFormatContext *ic,
1903  int index,
1904  const char *url,
1905  int is_output);
1906 #endif
1907 
1909  int index,
1910  const char *url,
1911  int is_output);
1912 
1913 #if FF_API_PARSE_DATE
1914 
1922 int64_t parse_date(const char *datestr, int duration);
1923 #endif
1924 
1928 int64_t av_gettime(void);
1929 
1930 #if FF_API_FIND_INFO_TAG
1931 
1934 attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
1935 #endif
1936 
1949 int av_get_frame_filename(char *buf, int buf_size,
1950  const char *path, int number);
1951 
1958 int av_filename_number_test(const char *filename);
1959 
1974 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1975 
1976 #if FF_API_SDP_CREATE
1977 attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
1978 #endif
1979 
1986 int av_match_ext(const char *filename, const char *extensions);
1987 
1996 int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance);
1997 
2013 const struct AVCodecTag *avformat_get_riff_video_tags(void);
2017 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
2026 #endif /* AVFORMAT_AVFORMAT_H */
unsigned int nb_chapters
Definition: avformat.h:1063
struct AVFormatParameters AVFormatParameters
struct AVOutputFormat AVOutputFormat
unsigned int max_index_size
Maximum amount of memory in bytes to use for the index of each stream.
Definition: avformat.h:1055
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:3710
unsigned int packet_size
Definition: avformat.h:973
static int write_header(AVFormatContext *s)
Definition: assenc.c:28
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:583
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
Interleave a packet per dts in an output media file.
Definition: utils.c:3213
struct AVInputFormat AVInputFormat
Bytestream IO Context.
Definition: avio.h:68
Buffered I/O operations.
int64_t start_time_realtime
Start time of the stream in real world time, in microseconds since the unix epoch (00:00 1st January ...
Definition: avformat.h:1103
int size
struct AVProgram AVProgram
New fields can be added to the end with minor version bumps.
int64_t(* read_timestamp)(struct AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
Get the next timestamp in stream[stream_index].time_base units.
Definition: avformat.h:522
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: utils.c:3262
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1127
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:1474
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
Definition: utils.c:2941
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: utils.c:3151
const char * filename
Definition: avformat.h:340
enum CodecID 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: utils.c:237
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:606
unsigned int max_picture_buffer
Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices...
Definition: avformat.h:1061
int64_t pos
Definition: avformat.h:588
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
enum PixelFormat pix_fmt
Definition: v4l.c:65
int width
Definition: rotozoom.c:164
void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st)
Send a nice dump of a packet to the specified file stream.
Definition: utils.c:3691
int64_t data_offset
offset of the first packet
Definition: avformat.h:1163
int priv_data_size
Size of private data so that it can be allocated in the wrapper.
Definition: avformat.h:472
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
Definition: avformat.h:919
int id
Definition: avformat.h:836
enum CodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1031
AVCodec.
Definition: avcodec.h:3189
static int64_t duration
Definition: avplay.c:241
struct AVPacketList * packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
Definition: avformat.h:1156
AVStream * cur_st
Definition: avformat.h:1160
Format I/O context.
Definition: avformat.h:863
unsigned int nb_stream_indexes
Definition: avformat.h:840
Public dictionary API.
int flags
Definition: avformat.h:837
int(* read_close)(struct AVFormatContext *)
Close the stream.
Definition: avformat.h:505
struct AVStream AVStream
Stream structure.
const struct AVCodecTag * avformat_get_riff_video_tags(void)
Definition: utils.c:4119
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK.
Definition: avformat.h:530
unsigned avformat_version(void)
Return the LIBAVFORMAT_VERSION_INT constant.
Definition: utils.c:56
const char * avformat_license(void)
Return the libavformat license.
Definition: utils.c:66
AVPacket pkt
Definition: avformat.h:1168
int(* read_header)(struct AVFormatContext *, AVFormatParameters *ap)
Read the format header and initialize the AVFormatContext structure.
Definition: avformat.h:487
AVStream ** streams
Definition: avformat.h:908
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:146
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
Definition: utils.c:61
#define MAX_REORDER_DELAY
Definition: avformat.h:812
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:570
AVProgram * av_new_program(AVFormatContext *s, int id)
Definition: utils.c:2826
static int flags
Definition: log.c:34
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum CodecID id)
Get the codec tag for the given codec id id.
uint32_t tag
Definition: movenc.c:670
int avformat_network_init(void)
Do global initialization of network components.
Definition: utils.c:4056
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
Definition: utils.c:4123
int fps_probe_size
decoding: number of frames used to probe fps
Definition: avformat.h:1108
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
Definition: sdp.c:636
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:269
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: utils.c:157
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:155
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Definition: avformat.h:838
unsigned int * stream_index
Definition: avformat.h:839
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:67
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
Definition: utils.c:3652
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:287
struct AVOutputFormat * oformat
Definition: avformat.h:877
int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance)
Test if the given container can store a codec.
Definition: utils.c:4042
struct AVPacketList * raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
Definition: avformat.h:1143
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Definition: utils.c:3452
Callback for checking whether to abort blocking functions.
Definition: avio.h:51
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:2619
enum CodecID codec_id
Definition: mov_chan.c:417
static int64_t start_time
Definition: avplay.c:240
AVDictionary * metadata
Definition: avformat.h:1085
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:1516
int(* read_probe)(AVProbeData *)
Tell if a given file has a chance of being parsed as this format.
Definition: avformat.h:479
struct AVCodecParser * parser
Definition: avcodec.h:4415
struct AVFrac AVFrac
The exact value of the fractional number is: 'val + num / den'.
int64_t timestamp
Definition: avformat.h:589
unsigned int nb_programs
Definition: avformat.h:1024
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
Definition: utils.c:2674
struct AVFormatContext AVFormatContext
Format I/O context.
AVChapter ** chapters
Definition: avformat.h:1064
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:2776
static AVDictionary * metadata
Definition: ffmpeg.c:185
AVDiscard
Definition: avcodec.h:522
New fields can be added to the end with minor version bumps.
Definition: avformat.h:835
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
Definition: utils.c:309
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
Definition: avformat.h:593
The exact value of the fractional number is: 'val + num / den'.
Definition: avformat.h:327
Only parse headers, do not repack.
Definition: avformat.h:582
static float distance(float x, float y, int band)
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:342
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:341
struct AVChapter AVChapter
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:907
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
Definition: utils.c:2683
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: utils.c:258
char filename[1024]
input or output filename
Definition: avformat.h:910
#define f(n)
Definition: regs.h:33
int av_find_default_stream_index(AVFormatContext *s)
Definition: utils.c:1341
int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
Definition: utils.c:494
enum CodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the CodecID for the given codec tag tag.
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: utils.c:202
void av_register_input_format(AVInputFormat *format)
Definition: utils.c:139
Libavformat version macros.
int(* read_pause)(struct AVFormatContext *)
Pause playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:554
unsigned int probesize
decoding: size of data to probe; encoding: unused.
Definition: avformat.h:1013
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in 'buf' the path with 'd' replaced by a number.
Definition: utils.c:3563
AVOutputFormat * av_oformat_next(AVOutputFormat *f)
If f is NULL, returns the first registered output format, if f is non-NULL, returns the next register...
Definition: utils.c:133
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:467
int raw_packet_buffer_remaining_size
Definition: avformat.h:1149
Stream structure.
Definition: avformat.h:620
void av_register_output_format(AVOutputFormat *format)
Definition: utils.c:148
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:4068
enum CodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1037
external API header
struct AVOutputFormat * next
Definition: avformat.h:445
int(* read_seek)(struct AVFormatContext *, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to the frames in stream component stream_index.
Definition: avformat.h:515
int value
General purpose read-only value that the format can use.
Definition: avformat.h:542
int debug
Flags to enable debugging.
Definition: avformat.h:1069
AVIOContext * pb
Definition: avformat.h:896
static const OptionDef options[]
Definition: avconv.c:105
main external API structure.
Definition: avcodec.h:1329
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:303
int(* read_packet)(struct AVFormatContext *, AVPacket *pkt)
Read one packet and put it in 'pkt'.
Definition: avformat.h:499
Describe the class of an AVClass context structure.
Definition: log.h:33
int index
Definition: gxfenc.c:73
struct AVPacketList AVPacketList
rational number numerator/denominator
Definition: rational.h:43
enum CodecID subtitle_codec_id
Forced subtitle codec_id.
Definition: avformat.h:1043
struct AVPacketList * packet_buffer_end
Definition: avformat.h:1157
static int loop_input
Definition: ffmpeg.c:152
const AVClass * av_class
A class for logging and AVOptions.
Definition: avformat.h:868
AVMediaType
Definition: avutil.h:228
enum CodecID id
Definition: mxfenc.c:85
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:2702
This structure contains the data a format has to probe a file.
Definition: avformat.h:339
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:1264
static int loop_output
Definition: ffmpeg.c:153
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:1839
full parsing and repack of the first frame only, only implemented for H.264 currently ...
Definition: avformat.h:584
AVDictionary * metadata
Definition: avformat.h:841
int64_t val
Definition: avformat.h:328
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
Definition: avformat.h:935
int64_t num
Definition: avformat.h:328
uint8_t level
Definition: svq3.c:123
#define attribute_deprecated
Definition: attributes.h:87
const char * name
Definition: audioconvert.c:61
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
Definition: utils.c:1796
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: utils.c:3252
int height
Definition: gxfenc.c:73
int64_t den
Definition: avformat.h:328
const char * extensions
If extensions are defined, then no probe is done.
Definition: avformat.h:537
const uint8_t * key
Definition: avformat.h:1021
full parsing and repack
Definition: avformat.h:581
PixelFormat
Pixel format.
Definition: pixfmt.h:62
void av_hex_dump(FILE *f, uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the specified file stream.
Definition: utils.c:3647
struct AVPacketList * next
Definition: avformat.h:1169
int(* read_play)(struct AVFormatContext *)
Start/resume playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:548
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2293
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1779
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
Definition: avformat.h:1116
AVStreamParseType
Definition: avformat.h:579
struct AVProbeData AVProbeData
This structure contains the data a format has to probe a file.
int max_analyze_duration
decoding: maximum time (in AV_TIME_BASE units) during which the input should be analyzed in avformat_...
Definition: avformat.h:1019
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
Definition: avformat.h:876
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2752
AVInputFormat * av_iformat_next(AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...
Definition: utils.c:127
CodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:83
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
Read a transport packet from a media file.
Definition: utils.c:700
void * priv_data
Format private data.
Definition: avformat.h:883
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: utils.c:3296
int bit_rate
Decoding: total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:957
struct AVIndexEntry AVIndexEntry
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:943
int(* read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
Definition: avformat.h:564
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:460
void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st)
Send a nice dump of a packet to the log.
Definition: utils.c:3704
struct AVInputFormat * next
Definition: avformat.h:573
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
Definition: utils.c:363
struct AVPacketList * raw_packet_buffer_end
Definition: avformat.h:1144
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:40
#define MAX_STD_TIMEBASES
Stream information used internally by av_find_stream_info()
Definition: avformat.h:773
const struct AVCodecTag *const * codec_tag
Definition: avformat.h:556
AVProgram ** programs
Definition: avformat.h:1025
int64_t av_gettime(void)
Get the current time in microseconds.
Definition: utils.c:3531