Libav
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 
253 #include <time.h>
254 #include <stdio.h> /* FILE */
255 #include "libavcodec/avcodec.h"
256 #include "libavutil/dict.h"
257 #include "libavutil/log.h"
258 
259 #include "avio.h"
260 #include "libavformat/version.h"
261 
262 struct AVFormatContext;
263 
264 
343 /* packet functions */
344 
345 
355 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
356 
357 
372 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
373 
374 #if FF_API_LAVF_FRAC
375 /*************************************************/
376 /* fractional numbers for exact pts handling */
377 
382 typedef struct AVFrac {
383  int64_t val, num, den;
384 } AVFrac;
385 #endif
386 
387 /*************************************************/
388 /* input/output formats */
389 
390 struct AVCodecTag;
391 
395 typedef struct AVProbeData {
396  const char *filename;
397  unsigned char *buf;
398  int buf_size;
400 } AVProbeData;
401 
402 #define AVPROBE_SCORE_EXTENSION 50
403 #define AVPROBE_SCORE_MIME 75
404 #define AVPROBE_SCORE_MAX 100
405 
406 #define AVPROBE_PADDING_SIZE 32
407 
408 #define AVFMT_NOFILE 0x0001
410 #define AVFMT_NEEDNUMBER 0x0002
411 #define AVFMT_SHOW_IDS 0x0008
412 #define AVFMT_RAWPICTURE 0x0020
414 #define AVFMT_GLOBALHEADER 0x0040
415 #define AVFMT_NOTIMESTAMPS 0x0080
416 #define AVFMT_GENERIC_INDEX 0x0100
417 #define AVFMT_TS_DISCONT 0x0200
418 #define AVFMT_VARIABLE_FPS 0x0400
419 #define AVFMT_NODIMENSIONS 0x0800
420 #define AVFMT_NOSTREAMS 0x1000
421 #define AVFMT_NOBINSEARCH 0x2000
422 #define AVFMT_NOGENSEARCH 0x4000
423 #define AVFMT_NO_BYTE_SEEK 0x8000
424 #define AVFMT_ALLOW_FLUSH 0x10000
425 #define AVFMT_TS_NONSTRICT 0x20000
428 #define AVFMT_TS_NEGATIVE 0x40000
438 typedef struct AVOutputFormat {
439  const char *name;
445  const char *long_name;
446  const char *mime_type;
447  const char *extensions;
448  /* output support */
449  enum AVCodecID audio_codec;
450  enum AVCodecID video_codec;
451  enum AVCodecID subtitle_codec;
458  int flags;
459 
464  const struct AVCodecTag * const *codec_tag;
466 
467  const AVClass *priv_class;
468 
469  /*****************************************************************
470  * No fields below this line are part of the public API. They
471  * may not be used outside of libavformat and can be changed and
472  * removed at will.
473  * New public fields should be added right above.
474  *****************************************************************
475  */
476  struct AVOutputFormat *next;
480  int priv_data_size;
481 
482  int (*write_header)(struct AVFormatContext *);
490  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
491  int (*write_trailer)(struct AVFormatContext *);
495  int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
496  AVPacket *in, int flush);
503  int (*query_codec)(enum AVCodecID id, int std_compliance);
513 typedef struct AVInputFormat {
518  const char *name;
519 
525  const char *long_name;
526 
532  int flags;
533 
539  const char *extensions;
540 
541  const struct AVCodecTag * const *codec_tag;
542 
543  const AVClass *priv_class;
544 
550  const char *mime_type;
551 
552  /*****************************************************************
553  * No fields below this line are part of the public API. They
554  * may not be used outside of libavformat and can be changed and
555  * removed at will.
556  * New public fields should be added right above.
557  *****************************************************************
558  */
559  struct AVInputFormat *next;
560 
564  int raw_codec_id;
565 
569  int priv_data_size;
570 
577 
583  int (*read_header)(struct AVFormatContext *);
584 
594  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
595 
600  int (*read_close)(struct AVFormatContext *);
610  int (*read_seek)(struct AVFormatContext *,
611  int stream_index, int64_t timestamp, int flags);
612 
617  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
618  int64_t *pos, int64_t pos_limit);
619 
624  int (*read_play)(struct AVFormatContext *);
625 
630  int (*read_pause)(struct AVFormatContext *);
638  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
639 } AVInputFormat;
644 enum AVStreamParseType {
650 };
652 typedef struct AVIndexEntry {
653  int64_t pos;
654  int64_t timestamp;
655 #define AVINDEX_KEYFRAME 0x0001
656  int flags:2;
657  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).
658  int min_distance;
661 #define AV_DISPOSITION_DEFAULT 0x0001
662 #define AV_DISPOSITION_DUB 0x0002
663 #define AV_DISPOSITION_ORIGINAL 0x0004
664 #define AV_DISPOSITION_COMMENT 0x0008
665 #define AV_DISPOSITION_LYRICS 0x0010
666 #define AV_DISPOSITION_KARAOKE 0x0020
667 
673 #define AV_DISPOSITION_FORCED 0x0040
674 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
675 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
676 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
683 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
684 
692 typedef struct AVStream {
693  int index;
699  int id;
712  void *priv_data;
713 
714 #if FF_API_LAVF_FRAC
715 
719  struct AVFrac pts;
720 #endif
721 
735 
742  int64_t start_time;
743 
749  int64_t duration;
750 
751  int64_t nb_frames;
752 
753  int disposition;
755  enum AVDiscard discard;
763 
765 
774 
783 
804  int nb_side_data;
805 
812 #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001
813 
814  /*****************************************************************
815  * All fields below this line are not part of the public API. They
816  * may not be used outside of libavformat and can be changed and
817  * removed at will.
818  * New public fields should be added right above.
819  *****************************************************************
820  */
821 
825 #define MAX_STD_TIMEBASES (60*12+5)
826  struct {
827  int nb_decoded_frames;
828  int found_decoder;
829 
833  int64_t fps_first_dts;
835  int64_t fps_last_dts;
836  int fps_last_dts_idx;
837 
838  } *info;
839 
842  // Timestamp generation support:
843  int64_t first_dts;
844  int64_t cur_dts;
845  int64_t last_IP_pts;
846  int last_IP_duration;
851 #define MAX_PROBE_PACKETS 2500
859  /* av_read_frame() support */
862 
868 #define MAX_REORDER_DELAY 16
869  int64_t pts_buffer[MAX_REORDER_DELAY+1];
870 
877 #define AV_PROGRAM_RUNNING 1
885 typedef struct AVProgram {
886  int id;
887  int flags;
888  enum AVDiscard discard;
889  unsigned int *stream_index;
890  unsigned int nb_stream_indexes;
894 #define AVFMTCTX_NOHEADER 0x0001
897 typedef struct AVChapter {
898  int id;
899  AVRational time_base;
900  int64_t start, end;
901  AVDictionary *metadata;
902 } AVChapter;
903 
904 typedef struct AVFormatInternal AVFormatInternal;
914 typedef struct AVFormatContext {
919  const AVClass *av_class;
920 
926  struct AVInputFormat *iformat;
933  struct AVOutputFormat *oformat;
942  void *priv_data;
943 
956  AVIOContext *pb;
957 
958  /* stream info */
963  int ctx_flags;
970  unsigned int nb_streams;
982  AVStream **streams;
983 
990  char filename[1024];
991 
999  int64_t start_time;
1000 
1009  int64_t duration;
1010 
1016  int bit_rate;
1018  unsigned int packet_size;
1019  int max_delay;
1020 
1025  int flags;
1026 #define AVFMT_FLAG_GENPTS 0x0001
1027 #define AVFMT_FLAG_IGNIDX 0x0002
1028 #define AVFMT_FLAG_NONBLOCK 0x0004
1029 #define AVFMT_FLAG_IGNDTS 0x0008
1030 #define AVFMT_FLAG_NOFILLIN 0x0010
1031 #define AVFMT_FLAG_NOPARSE 0x0020
1032 #define AVFMT_FLAG_NOBUFFER 0x0040
1033 #define AVFMT_FLAG_CUSTOM_IO 0x0080
1034 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100
1035 #define AVFMT_FLAG_FLUSH_PACKETS 0x0200
1042 #define AVFMT_FLAG_BITEXACT 0x0400
1049  unsigned int probesize;
1058  const uint8_t *key;
1059  int keylen;
1060 
1061  unsigned int nb_programs;
1062  AVProgram **programs;
1063 
1075 
1081 
1092  unsigned int max_index_size;
1093 
1098  unsigned int max_picture_buffer;
1099 
1111  unsigned int nb_chapters;
1112  AVChapter **chapters;
1113 
1123 
1131 
1137  int fps_probe_size;
1144  int error_recognition;
1156 
1160  int debug;
1161 #define FF_FDEBUG_TS 0x0001
1162 
1179  int64_t max_interleave_delta;
1180 
1186 
1192  int event_flags;
1193 #define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001
1194 
1195  /*****************************************************************
1196  * All fields below this line are not part of the public API. They
1197  * may not be used outside of libavformat and can be changed and
1198  * removed at will.
1199  * New public fields should be added right above.
1200  *****************************************************************
1201  */
1202 
1208  struct AVPacketList *packet_buffer;
1210 
1211  /* av_seek_frame() support */
1212  int64_t data_offset;
1225  struct AVPacketList *parse_queue;
1226  struct AVPacketList *parse_queue_end;
1230 #define RAW_PACKET_BUFFER_SIZE 2500000
1232 
1237  int64_t offset;
1243 
1248  AVFormatInternal *internal;
1249 } AVFormatContext;
1251 typedef struct AVPacketList {
1252  AVPacket pkt;
1253  struct AVPacketList *next;
1254 } AVPacketList;
1255 
1269 unsigned avformat_version(void);
1270 
1274 const char *avformat_configuration(void);
1275 
1279 const char *avformat_license(void);
1280 
1290 void av_register_all(void);
1291 
1294 
1303 int avformat_network_init(void);
1304 
1308 int avformat_network_deinit(void);
1309 
1316 
1323 
1330 
1336 
1343 const AVClass *avformat_get_class(void);
1344 
1362 
1372  enum AVPacketSideDataType type, int *size);
1373 
1375 
1389 AVInputFormat *av_find_input_format(const char *short_name);
1390 
1398 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
1399 
1412 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
1413 
1430  const char *filename, void *logctx,
1431  unsigned int offset, unsigned int max_probe_size);
1432 
1452 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
1453 
1476 
1502  enum AVMediaType type,
1503  int wanted_stream_nb,
1504  int related_stream,
1505  AVCodec **decoder_ret,
1506  int flags);
1507 
1533 
1547 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
1548  int flags);
1549 
1577 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
1578 
1584 
1591 
1601 #define AVSEEK_FLAG_BACKWARD 1
1602 #define AVSEEK_FLAG_BYTE 2
1603 #define AVSEEK_FLAG_ANY 4
1604 #define AVSEEK_FLAG_FRAME 8
1605 
1606 
1626 
1658 
1693 
1704 
1717 AVOutputFormat *av_guess_format(const char *short_name,
1718  const char *filename,
1719  const char *mime_type);
1720 
1724 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
1725  const char *filename, const char *mime_type,
1726  enum AVMediaType type);
1727 
1751 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
1752 
1765 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
1766 
1775 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
1776 
1777 
1789 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1790  AVStream *st);
1791 
1800 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
1801 
1810 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
1811 
1813 
1825 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1826 
1833 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1834  int size, int distance, int flags);
1835 
1836 
1856 void av_url_split(char *proto, int proto_size,
1857  char *authorization, int authorization_size,
1858  char *hostname, int hostname_size,
1859  int *port_ptr,
1860  char *path, int path_size,
1861  const char *url);
1862 
1863 
1875  int index,
1876  const char *url,
1877  int is_output);
1878 
1891 int av_get_frame_filename(char *buf, int buf_size,
1892  const char *path, int number);
1893 
1900 int av_filename_number_test(const char *filename);
1901 
1919 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1920 
1928 int av_match_ext(const char *filename, const char *extensions);
1929 
1941  int std_compliance);
1942 
1958 const struct AVCodecTag *avformat_get_riff_video_tags(void);
1962 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
1971 #endif /* AVFORMAT_AVFORMAT_H */
unsigned int nb_chapters
Number of chapters in AVChapter array.
Definition: avformat.h:1119
unsigned int max_index_size
Maximum amount of memory in bytes to use for the index of each stream.
Definition: avformat.h:1100
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:2705
struct AVPacketList * raw_packet_buffer_end
Definition: avformat.h:1229
unsigned int packet_size
Definition: avformat.h:1026
int64_t first_dts
Definition: avformat.h:850
Bytestream IO Context.
Definition: avio.h:68
AVProbeData probe_data
Definition: avformat.h:874
AVPacketSideDataType
Definition: avcodec.h:858
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:1138
int size
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:624
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: mux.c:533
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1163
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:1181
struct AVPacketList * packet_buffer_end
Definition: avformat.h:1217
enum AVCodecID id
Definition: mxfenc.c:84
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:238
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: mux.c:361
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:525
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
Definition: format.c:171
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:247
unsigned int max_picture_buffer
Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices...
Definition: avformat.h:1106
int64_t pos
Definition: avformat.h:660
int probe_packets
Definition: avformat.h:859
int event_flags
Flags for the user to detect events happening on the stream.
Definition: avformat.h:818
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:718
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:769
int index
stream index in AVFormatContext
Definition: avformat.h:700
AVStreamParseType
Definition: avformat.h:651
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
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: dump.c:103
int event_flags
Flags for the user to detect events happening on the file.
Definition: avformat.h:1200
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
Definition: avformat.h:807
int64_t data_offset
offset of the first packet
Definition: avformat.h:1220
int priv_data_size
Size of private data so that it can be allocated in the wrapper.
Definition: avformat.h:576
int ctx_flags
Flags signalling stream properties.
Definition: avformat.h:971
int id
Definition: avformat.h:893
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.
Definition: avformat.h:1088
AVCodec.
Definition: avcodec.h:2796
int strict_std_compliance
Allow non-standard and experimental extension.
Definition: avformat.h:1193
AVDictionary * metadata
Definition: avformat.h:771
Format I/O context.
Definition: avformat.h:922
const char * mime_type
Comma-separated list of mime types.
Definition: avformat.h:557
unsigned int nb_stream_indexes
Definition: avformat.h:897
int64_t cur_dts
Definition: avformat.h:851
int64_t pts_buffer[MAX_REORDER_DELAY+1]
Definition: avformat.h:876
int flags
Definition: avformat.h:894
int(* read_close)(struct AVFormatContext *)
Close the stream.
Definition: avformat.h:607
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:532
uint8_t
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
Definition: format.c:228
const char * extensions
If extensions are defined, then no probe is done.
Definition: avformat.h:546
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:539
struct AVPacketList * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
Definition: avformat.h:873
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:58
AVPacket pkt
Definition: avformat.h:1260
int priv_data_size
size of private data so that it can be allocated in the wrapper
Definition: avformat.h:487
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:397
enum AVStreamParseType need_parsing
Definition: avformat.h:867
int id
Format-specific stream ID.
Definition: avformat.h:706
int nb_side_data
The number of elements in the AVStream.side_data array.
Definition: avformat.h:811
const char * name
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
Definition: riff.c:443
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1033
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:550
int(* read_header)(struct AVFormatContext *)
Read the format header and initialize the AVFormatContext structure.
Definition: avformat.h:590
int64_t max_interleave_delta
Maximum buffering duration for interleaving.
Definition: avformat.h:1187
static int flags
Definition: log.c:44
uint32_t tag
Definition: movenc.c:844
int avformat_network_init(void)
Do global initialization of network components.
Definition: utils.c:2942
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:878
void * priv_data
Definition: avformat.h:719
int fps_probe_size
The number of frames used for determining the framerate in avformat_find_stream_info().
Definition: avformat.h:1145
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
Definition: sdp.c:689
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:77
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Definition: avformat.h:895
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:2518
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: mux.c:522
int64_t offset
Offset to remap timestamps to be non-negative.
Definition: avformat.h:1245
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1076
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:64
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:117
const OptionDef options[]
Definition: avconv_opt.c:2187
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:395
#define attribute_deprecated
Definition: attributes.h:80
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:2373
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:105
uint8_t * av_stream_get_side_data(AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
Definition: utils.c:3107
int nb_decoded_frames
Definition: avformat.h:834
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:1222
int(* read_probe)(AVProbeData *)
Tell if a given file has a chance of being parsed as this format.
Definition: avformat.h:583
AVRational offset_timebase
Timebase for the timestamp offset.
Definition: avformat.h:1250
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:69
struct AVStream::@4 * info
void * priv_data
Format private data.
Definition: avformat.h:950
char filename[1024]
input or output filename
Definition: avformat.h:998
int64_t timestamp
Definition: avformat.h:661
unsigned int nb_programs
Definition: avformat.h:1069
int last_IP_duration
Definition: avformat.h:853
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
Definition: utils.c:2427
struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:934
enum AVCodecID codec_id
Definition: mov_chan.c:432
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:780
New fields can be added to the end with minor version bumps.
Definition: avformat.h:892
Buffered I/O operations.
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
Definition: avformat.h:665
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:2926
static float distance(float x, float y, int band)
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:398
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:978
int64_t fps_first_dts
Those are used for average framerate estimation.
Definition: avformat.h:840
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
Definition: utils.c:2436
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1082
full parsing and repack
Definition: avformat.h:653
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:139
const char * filename
Definition: avformat.h:396
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:990
int av_find_default_stream_index(AVFormatContext *s)
Definition: utils.c:1056
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: format.c:238
struct AVOutputFormat * next
Definition: avformat.h:483
AVProgram * av_new_program(AVFormatContext *s, int id)
Definition: utils.c:2570
void av_register_input_format(AVInputFormat *format)
Definition: format.c:55
int(* read_pause)(struct AVFormatContext *)
Pause playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:637
const uint8_t * key
Definition: avformat.h:1066
unsigned int probesize
Maximum size of the data read from input for determining the input container format.
Definition: avformat.h:1057
struct AVPacketList * parse_queue_end
Definition: avformat.h:1234
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:2652
int raw_packet_buffer_remaining_size
Definition: avformat.h:1239
Stream structure.
Definition: avformat.h:699
void av_register_output_format(AVOutputFormat *format)
Definition: format.c:66
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:2954
struct AVPacketList * raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
Definition: avformat.h:1228
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:617
int debug
Flags to enable debugging.
Definition: avformat.h:1168
main external API structure.
Definition: avcodec.h:1050
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:134
int(* read_packet)(struct AVFormatContext *, AVPacket *pkt)
Read one packet and put it in 'pkt'.
Definition: avformat.h:601
AVIOContext * pb
I/O context.
Definition: avformat.h:964
int nb_index_entries
Definition: avformat.h:880
Describe the class of an AVClass context structure.
Definition: log.h:33
full parsing and repack of the first frame only, only implemented for H.264 currently ...
Definition: avformat.h:656
int index
Definition: gxfenc.c:72
rational number numerator/denominator
Definition: rational.h:43
const struct AVCodecTag * avformat_get_riff_video_tags(void)
Definition: riff.c:438
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1130
AVMediaType
Definition: avutil.h:185
int64_t fps_last_dts
Definition: avformat.h:842
int found_decoder
Definition: avformat.h:835
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:2445
This structure contains the data a format has to probe a file.
Definition: avformat.h:395
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:989
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:127
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:1542
AVDictionary * metadata
Definition: avformat.h:898
int raw_codec_id
Raw demuxers store their codec ID here.
Definition: avformat.h:571
AVInputFormat * av_iformat_next(const AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...
Definition: format.c:39
int fps_first_dts_idx
Definition: avformat.h:841
struct AVInputFormat * next
Definition: avformat.h:566
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
Definition: avformat.h:1007
uint8_t level
Definition: svq3.c:147
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
Definition: utils.c:1531
struct AVCodecParserContext * parser
Definition: avformat.h:868
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:756
const AVClass * av_class
A class for logging and AVOptions.
Definition: avformat.h:927
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
uint8_t * mime_type
mime_type, when known.
Definition: avformat.h:399
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:114
int(* read_play)(struct AVFormatContext *)
Start/resume playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:631
AVOutputFormat * av_oformat_next(const AVOutputFormat *f)
If f is NULL, returns the first registered output format, if f is non-NULL, returns the next register...
Definition: format.c:47
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2052
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1771
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
Definition: avformat.h:749
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
Definition: avformat.h:1152
int disposition
AV_DISPOSITION_* bit field.
Definition: avformat.h:760
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:98
int pts_wrap_bits
number of bits in pts (used for wrapping control)
Definition: avformat.h:847
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:758
int max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
Definition: avformat.h:1064
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2496
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:1216
unsigned int index_entries_allocated_size
Definition: avformat.h:881
struct AVOutputFormat * oformat
The output container format.
Definition: avformat.h:941
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:655
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:104
int codec_info_nb_frames
Number of frames that have been demuxed during av_find_stream_info()
Definition: avformat.h:864
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:380
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
Definition: utils.c:63
AVDiscard
Definition: avcodec.h:560
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: mux.c:583
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1024
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1017
const struct AVCodecTag *const * codec_tag
Definition: avformat.h:548
int64_t last_IP_pts
Definition: avformat.h:852
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:645
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: dump.c:108
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:74
int fps_last_dts_idx
Definition: avformat.h:843
#define MAX_REORDER_DELAY
Definition: avformat.h:875
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:741
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
AVProgram ** programs
Definition: avformat.h:1070
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:762
AVChapter ** chapters
Definition: avformat.h:1120
struct AVPacketList * parse_queue
Packets split by the parser get queued here.
Definition: avformat.h:1233
unsigned int * stream_index
Definition: avformat.h:896
This structure stores compressed data.
Definition: avcodec.h:950
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:51
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
Definition: avformat.h:789
const char * avformat_license(void)
Return the libavformat license.
Definition: utils.c:68
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:162
struct AVPacketList * next
Definition: avformat.h:1261
Only parse headers, do not repack.
Definition: avformat.h:654