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 
201 #include <time.h>
202 #include <stdio.h> /* FILE */
203 #include "libavcodec/avcodec.h"
204 #include "libavutil/dict.h"
205 #include "libavutil/log.h"
206 
207 #include "avio.h"
208 #include "libavformat/version.h"
209 
210 #if FF_API_AV_GETTIME
211 #include "libavutil/time.h"
212 #endif
213 
214 struct AVFormatContext;
215 
216 
290 /* packet functions */
291 
292 
301 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
302 
303 
317 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
318 
319 /*************************************************/
320 /* fractional numbers for exact pts handling */
321 
326 typedef struct AVFrac {
327  int64_t val, num, den;
328 } AVFrac;
329 
330 /*************************************************/
331 /* input/output formats */
332 
333 struct AVCodecTag;
334 
338 typedef struct AVProbeData {
339  const char *filename;
340  unsigned char *buf;
341  int buf_size;
342 } AVProbeData;
343 
344 #define AVPROBE_SCORE_MAX 100
345 #define AVPROBE_PADDING_SIZE 32
346 
347 #define AVFMT_NOFILE 0x0001
349 #define AVFMT_NEEDNUMBER 0x0002
350 #define AVFMT_SHOW_IDS 0x0008
351 #define AVFMT_RAWPICTURE 0x0020
353 #define AVFMT_GLOBALHEADER 0x0040
354 #define AVFMT_NOTIMESTAMPS 0x0080
355 #define AVFMT_GENERIC_INDEX 0x0100
356 #define AVFMT_TS_DISCONT 0x0200
357 #define AVFMT_VARIABLE_FPS 0x0400
358 #define AVFMT_NODIMENSIONS 0x0800
359 #define AVFMT_NOSTREAMS 0x1000
360 #define AVFMT_NOBINSEARCH 0x2000
361 #define AVFMT_NOGENSEARCH 0x4000
362 #define AVFMT_NO_BYTE_SEEK 0x8000
363 #define AVFMT_ALLOW_FLUSH 0x10000
364 #define AVFMT_TS_NONSTRICT 0x20000
372 typedef struct AVOutputFormat {
373  const char *name;
379  const char *long_name;
380  const char *mime_type;
381  const char *extensions;
382  /* output support */
383  enum AVCodecID audio_codec;
384  enum AVCodecID video_codec;
385  enum AVCodecID subtitle_codec;
392  int flags;
393 
398  const struct AVCodecTag * const *codec_tag;
399 
400 
401  const AVClass *priv_class;
402 
403  /*****************************************************************
404  * No fields below this line are part of the public API. They
405  * may not be used outside of libavformat and can be changed and
406  * removed at will.
407  * New public fields should be added right above.
408  *****************************************************************
409  */
410  struct AVOutputFormat *next;
414  int priv_data_size;
415 
416  int (*write_header)(struct AVFormatContext *);
424  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
425  int (*write_trailer)(struct AVFormatContext *);
429  int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
430  AVPacket *in, int flush);
437  int (*query_codec)(enum AVCodecID id, int std_compliance);
447 typedef struct AVInputFormat {
452  const char *name;
453 
459  const char *long_name;
460 
466  int flags;
467 
473  const char *extensions;
474 
475  const struct AVCodecTag * const *codec_tag;
477  const AVClass *priv_class;
479  /*****************************************************************
480  * No fields below this line are part of the public API. They
481  * may not be used outside of libavformat and can be changed and
482  * removed at will.
483  * New public fields should be added right above.
484  *****************************************************************
485  */
486  struct AVInputFormat *next;
487 
491  int raw_codec_id;
492 
496  int priv_data_size;
497 
503  int (*read_probe)(AVProbeData *);
504 
510  int (*read_header)(struct AVFormatContext *);
511 
521  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
522 
527  int (*read_close)(struct AVFormatContext *);
528 
537  int (*read_seek)(struct AVFormatContext *,
538  int stream_index, int64_t timestamp, int flags);
539 
544  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
545  int64_t *pos, int64_t pos_limit);
546 
551  int (*read_play)(struct AVFormatContext *);
552 
557  int (*read_pause)(struct AVFormatContext *);
558 
565  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
566 } AVInputFormat;
571 enum AVStreamParseType {
577 };
579 typedef struct AVIndexEntry {
580  int64_t pos;
581  int64_t timestamp;
582 #define AVINDEX_KEYFRAME 0x0001
583  int flags:2;
584  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).
588 #define AV_DISPOSITION_DEFAULT 0x0001
589 #define AV_DISPOSITION_DUB 0x0002
590 #define AV_DISPOSITION_ORIGINAL 0x0004
591 #define AV_DISPOSITION_COMMENT 0x0008
592 #define AV_DISPOSITION_LYRICS 0x0010
593 #define AV_DISPOSITION_KARAOKE 0x0020
600 #define AV_DISPOSITION_FORCED 0x0040
601 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
602 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
603 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
610 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
611 
619 typedef struct AVStream {
620  int index;
626  int id;
639 #if FF_API_R_FRAME_RATE
640 
648  AVRational r_frame_rate;
649 #endif
650  void *priv_data;
651 
655  struct AVFrac pts;
656 
667 
674  int64_t start_time;
675 
681  int64_t duration;
682 
683  int64_t nb_frames;
685  int disposition;
687  enum AVDiscard discard;
695 
702 
711 
712  /*****************************************************************
713  * All fields below this line are not part of the public API. They
714  * may not be used outside of libavformat and can be changed and
715  * removed at will.
716  * New public fields should be added right above.
717  *****************************************************************
718  */
719 
723 #define MAX_STD_TIMEBASES (60*12+5)
724  struct {
725 #if FF_API_R_FRAME_RATE
726  int64_t last_dts;
727  int64_t duration_gcd;
728  int duration_count;
729  double duration_error[MAX_STD_TIMEBASES];
730 #endif
731  int nb_decoded_frames;
732  int found_decoder;
733 
737  int64_t fps_first_dts;
738  int fps_first_dts_idx;
739  int64_t fps_last_dts;
742  } *info;
744  int pts_wrap_bits;
746  // Timestamp generation support:
754  int64_t reference_dts;
755  int64_t first_dts;
756  int64_t cur_dts;
757  int64_t last_IP_pts;
763 #define MAX_PROBE_PACKETS 2500
764  int probe_packets;
765 
770 
771  /* av_read_frame() support */
774 
780 #define MAX_REORDER_DELAY 16
785  int nb_index_entries;
787 } AVStream;
789 #define AV_PROGRAM_RUNNING 1
790 
797 typedef struct AVProgram {
798  int id;
799  int flags;
801  unsigned int *stream_index;
802  unsigned int nb_stream_indexes;
806 #define AVFMTCTX_NOHEADER 0x0001
809 typedef struct AVChapter {
810  int id;
811  AVRational time_base;
812  int64_t start, end;
813  AVDictionary *metadata;
824 typedef struct AVFormatContext {
829  const AVClass *av_class;
830 
837  struct AVInputFormat *iformat;
838  struct AVOutputFormat *oformat;
839 
844  void *priv_data;
845 
857  AVIOContext *pb;
858 
859  /* stream info */
860  int ctx_flags;
871  unsigned int nb_streams;
872  AVStream **streams;
873 
874  char filename[1024];
881  int64_t start_time;
882 
889  int64_t duration;
890 
896  int bit_rate;
897 
898  unsigned int packet_size;
899  int max_delay;
901  int flags;
902 #define AVFMT_FLAG_GENPTS 0x0001
903 #define AVFMT_FLAG_IGNIDX 0x0002
904 #define AVFMT_FLAG_NONBLOCK 0x0004
905 #define AVFMT_FLAG_IGNDTS 0x0008
906 #define AVFMT_FLAG_NOFILLIN 0x0010
907 #define AVFMT_FLAG_NOPARSE 0x0020
908 #define AVFMT_FLAG_NOBUFFER 0x0040
909 #define AVFMT_FLAG_CUSTOM_IO 0x0080
910 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100
915  unsigned int probesize;
916 
922 
923  const uint8_t *key;
924  int keylen;
926  unsigned int nb_programs;
934 
940 
946 
957  unsigned int max_index_size;
958 
963  unsigned int max_picture_buffer;
964 
965  unsigned int nb_chapters;
977  int64_t start_time_realtime;
978 
982  int fps_probe_size;
983 
990  int error_recognition;
991 
1002 
1006  int debug;
1007 #define FF_FDEBUG_TS 0x0001
1008  /*****************************************************************
1009  * All fields below this line are not part of the public API. They
1010  * may not be used outside of libavformat and can be changed and
1011  * removed at will.
1012  * New public fields should be added right above.
1013  *****************************************************************
1014  */
1015 
1021  struct AVPacketList *packet_buffer;
1023 
1024  /* av_seek_frame() support */
1025  int64_t data_offset;
1039  struct AVPacketList *parse_queue_end;
1043 #define RAW_PACKET_BUFFER_SIZE 2500000
1045 } AVFormatContext;
1046 
1047 typedef struct AVPacketList {
1049  struct AVPacketList *next;
1050 } AVPacketList;
1065 unsigned avformat_version(void);
1066 
1070 const char *avformat_configuration(void);
1071 
1075 const char *avformat_license(void);
1076 
1086 void av_register_all(void);
1087 
1090 
1099 int avformat_network_init(void);
1100 
1104 int avformat_network_deinit(void);
1105 
1112 
1119 
1126 
1132 
1139 const AVClass *avformat_get_class(void);
1140 
1157 
1159 
1173 AVInputFormat *av_find_input_format(const char *short_name);
1174 
1181 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
1182 
1194 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
1195 
1212  const char *filename, void *logctx,
1213  unsigned int offset, unsigned int max_probe_size);
1214 
1234 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
1235 
1258 
1284  enum AVMediaType type,
1285  int wanted_stream_nb,
1286  int related_stream,
1287  AVCodec **decoder_ret,
1288  int flags);
1289 
1290 #if FF_API_READ_PACKET
1291 
1305 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
1306 #endif
1307 
1333 
1345 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
1346  int flags);
1347 
1374 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
1375 
1381 
1388 
1389 #if FF_API_CLOSE_INPUT_FILE
1390 
1397 void av_close_input_file(AVFormatContext *s);
1398 #endif
1399 
1409 #define AVSEEK_FLAG_BACKWARD 1
1410 #define AVSEEK_FLAG_BYTE 2
1411 #define AVSEEK_FLAG_ANY 4
1412 #define AVSEEK_FLAG_FRAME 8
1434 
1452 
1480 
1481 #if FF_API_INTERLEAVE_PACKET
1482 
1487 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
1488  AVPacket *pkt, int flush);
1489 #endif
1490 
1501 
1514 AVOutputFormat *av_guess_format(const char *short_name,
1515  const char *filename,
1516  const char *mime_type);
1517 
1521 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
1522  const char *filename, const char *mime_type,
1523  enum AVMediaType type);
1524 
1548 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
1549 
1562 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
1563 
1572 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
1573 
1574 
1586 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1587  AVStream *st);
1588 
1596 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
1597 
1605 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
1606 
1608 
1617 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1618 
1625 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1626  int size, int distance, int flags);
1627 
1628 
1648 void av_url_split(char *proto, int proto_size,
1649  char *authorization, int authorization_size,
1650  char *hostname, int hostname_size,
1651  int *port_ptr,
1652  char *path, int path_size,
1653  const char *url);
1654 
1655 
1657  int index,
1658  const char *url,
1659  int is_output);
1660 
1673 int av_get_frame_filename(char *buf, int buf_size,
1674  const char *path, int number);
1675 
1682 int av_filename_number_test(const char *filename);
1683 
1701 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1702 
1709 int av_match_ext(const char *filename, const char *extensions);
1710 
1719 int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance);
1720 
1736 const struct AVCodecTag *avformat_get_riff_video_tags(void);
1740 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
1749 #endif /* AVFORMAT_AVFORMAT_H */
unsigned int nb_chapters
Definition: avformat.h:969
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:961
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:3173
unsigned int packet_size
Definition: avformat.h:902
int64_t first_dts
Definition: avformat.h:758
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:578
struct AVInputFormat AVInputFormat
Bytestream IO Context.
Definition: avio.h:68
AVProbeData probe_data
Definition: avformat.h:782
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:981
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:547
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: mux.c:524
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1005
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:1393
enum AVCodecID id
Definition: mxfenc.c:85
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:295
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: mux.c:394
const char * filename
Definition: avformat.h:339
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:476
int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
Definition: utils.c:3514
int64_t pts_buffer[MAX_REORDER_DELAY+1]
Definition: avformat.h:784
unsigned int max_picture_buffer
Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices...
Definition: avformat.h:967
int64_t pos
Definition: avformat.h:583
int probe_packets
Definition: avformat.h:767
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:697
int index
stream index in AVFormatContext
Definition: avformat.h:623
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:786
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:3162
void * priv_data
Definition: avformat.h:653
int64_t data_offset
offset of the first packet
Definition: avformat.h:1029
struct AVStream::@75 * info
int priv_data_size
Size of private data so that it can be allocated in the wrapper.
Definition: avformat.h:499
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
Definition: avformat.h:864
int id
Definition: avformat.h:801
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.
Definition: avformat.h:949
AVCodec.
Definition: avcodec.h:2960
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:1025
Format I/O context.
Definition: avformat.h:828
unsigned int nb_stream_indexes
Definition: avformat.h:805
int64_t cur_dts
Definition: avformat.h:759
Public dictionary API.
int flags
Definition: avformat.h:802
int(* read_close)(struct AVFormatContext *)
Close the stream.
Definition: avformat.h:530
uint8_t
struct AVStream AVStream
Stream structure.
const struct AVCodecTag * avformat_get_riff_video_tags(void)
Definition: utils.c:3591
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:469
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:55
const char * avformat_license(void)
Return the libavformat license.
Definition: utils.c:65
AVPacket pkt
Definition: avformat.h:1052
int priv_data_size
size of private data so that it can be allocated in the wrapper
Definition: avformat.h:417
enum AVStreamParseType need_parsing
Definition: avformat.h:775
int id
Format-specific stream ID.
Definition: avformat.h:629
const char * name
AVStream ** streams
Definition: avformat.h:876
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:97
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
Definition: utils.c:60
#define MAX_REORDER_DELAY
Definition: avformat.h:783
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:480
AVProgram * av_new_program(AVFormatContext *s, int id)
Definition: utils.c:2792
int(* read_header)(struct AVFormatContext *)
Read the format header and initialize the AVFormatContext structure.
Definition: avformat.h:513
static int flags
Definition: log.c:42
uint32_t tag
Definition: movenc.c:802
int avformat_network_init(void)
Do global initialization of network components.
Definition: utils.c:3528
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
Definition: utils.c:3595
int fps_probe_size
decoding: number of frames used to probe fps
Definition: avformat.h:986
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
Definition: sdp.c:676
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:218
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:106
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:106
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Definition: avformat.h:803
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: mux.c:513
unsigned int * stream_index
Definition: avformat.h:804
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:937
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:67
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:236
struct AVOutputFormat * oformat
Definition: avformat.h:842
struct AVPacketList * raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
Definition: avformat.h:1037
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Definition: utils.c:2952
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:2589
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:95
AVDictionary * metadata
Definition: avformat.h:972
int nb_decoded_frames
Definition: avformat.h:734
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:1435
int(* read_probe)(AVProbeData *)
Tell if a given file has a chance of being parsed as this format.
Definition: avformat.h:506
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: utils.c:3127
struct AVFrac AVFrac
The exact value of the fractional number is: 'val + num / den'.
int64_t timestamp
Definition: avformat.h:584
unsigned int nb_programs
Definition: avformat.h:930
int last_IP_duration
Definition: avformat.h:761
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
Definition: utils.c:2644
struct AVFormatContext AVFormatContext
Format I/O context.
AVChapter ** chapters
Definition: avformat.h:970
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:2736
enum AVCodecID codec_id
Definition: mov_chan.c:432
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:704
New fields can be added to the end with minor version bumps.
Definition: avformat.h:800
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
Definition: utils.c:258
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
Definition: avformat.h:588
The exact value of the fractional number is: 'val + num / den'.
Definition: avformat.h:326
Only parse headers, do not repack.
Definition: avformat.h:577
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:641
static float distance(float x, float y, int band)
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:341
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:340
struct AVChapter AVChapter
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:875
int64_t fps_first_dts
Those are used for average framerate estimation.
Definition: avformat.h:740
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
Definition: utils.c:2653
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: utils.c:207
char filename[1024]
input or output filename
Definition: avformat.h:878
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:943
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: utils.c:186
int av_find_default_stream_index(AVFormatContext *s)
Definition: utils.c:1272
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:356
AVDictionary * metadata
Definition: avformat.h:699
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:151
void av_register_input_format(AVInputFormat *format)
Definition: utils.c:88
Libavformat version macros.
int(* read_pause)(struct AVFormatContext *)
Pause playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:560
unsigned int probesize
decoding: size of data to probe; encoding: unused.
Definition: avformat.h:919
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:3043
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:82
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:462
int raw_packet_buffer_remaining_size
Definition: avformat.h:1048
Stream structure.
Definition: avformat.h:622
void av_register_output_format(AVOutputFormat *format)
Definition: utils.c:97
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:3540
external API header
struct AVOutputFormat * next
Definition: avformat.h:413
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:540
int debug
Flags to enable debugging.
Definition: avformat.h:1010
AVIOContext * pb
I/O context.
Definition: avformat.h:861
int64_t reference_dts
Timestamp corresponding to the last dts sync point.
Definition: avformat.h:757
main external API structure.
Definition: avcodec.h:1339
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:252
int(* read_packet)(struct AVFormatContext *, AVPacket *pkt)
Read one packet and put it in 'pkt'.
Definition: avformat.h:524
int nb_index_entries
Definition: avformat.h:788
Describe the class of an AVClass context structure.
Definition: log.h:33
int index
Definition: gxfenc.c:72
struct AVPacketList AVPacketList
rational number numerator/denominator
Definition: rational.h:43
struct AVPacketList * packet_buffer_end
Definition: avformat.h:1026
const AVClass * av_class
A class for logging and AVOptions.
Definition: avformat.h:833
AVMediaType
Definition: avutil.h:177
int64_t fps_last_dts
Definition: avformat.h:742
int found_decoder
Definition: avformat.h:735
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:2662
This structure contains the data a format has to probe a file.
Definition: avformat.h:338
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:1206
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:1740
full parsing and repack of the first frame only, only implemented for H.264 currently ...
Definition: avformat.h:579
int raw_codec_id
Raw demuxers store their codec ID here.
Definition: avformat.h:494
struct AVPacketList * parse_queue_end
Definition: avformat.h:1043
AVDictionary * metadata
Definition: avformat.h:806
int fps_first_dts_idx
Definition: avformat.h:741
struct AVPacketList * parse_queue
Packets split by the parser get queued here.
Definition: avformat.h:1042
int64_t val
Definition: avformat.h:327
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
Definition: avformat.h:885
int64_t num
Definition: avformat.h:327
uint8_t level
Definition: svq3.c:125
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
Definition: utils.c:1730
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:684
int64_t den
Definition: avformat.h:327
const OptionDef options[]
Definition: avserver.c:4665
const char * extensions
If extensions are defined, then no probe is done.
Definition: avformat.h:476
const uint8_t * key
Definition: avformat.h:927
full parsing and repack
Definition: avformat.h:576
struct AVPacketList * next
Definition: avformat.h:1053
int(* read_play)(struct AVFormatContext *)
Start/resume playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:554
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2236
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1772
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
Definition: avformat.h:677
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
Definition: avformat.h:994
int disposition
AV_DISPOSITION_* bit field.
Definition: avformat.h:688
AVStreamParseType
Definition: avformat.h:574
int pts_wrap_bits
number of bits in pts (used for wrapping control)
Definition: avformat.h:747
struct AVProbeData AVProbeData
This structure contains the data a format has to probe a file.
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:686
int max_analyze_duration
decoding: maximum time (in AV_TIME_BASE units) during which the input should be analyzed in avformat_...
Definition: avformat.h:925
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
Definition: avformat.h:841
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2713
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:76
unsigned int index_entries_allocated_size
Definition: avformat.h:789
struct AVCodecParserContext * parser
Definition: avformat.h:776
void * priv_data
Format private data.
Definition: avformat.h:848
int codec_info_nb_frames
Number of frames that have been demuxed during av_find_stream_info()
Definition: avformat.h:772
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:380
AVDiscard
Definition: avcodec.h:528
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: mux.c:565
int bit_rate
Decoding: total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:900
struct AVIndexEntry AVIndexEntry
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:893
int64_t last_IP_pts
Definition: avformat.h:760
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:568
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:455
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:3167
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: utils.c:3132
int fps_last_dts_idx
Definition: avformat.h:743
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:669
struct AVInputFormat * next
Definition: avformat.h:489
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:690
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
Definition: utils.c:312
struct AVPacketList * raw_packet_buffer_end
Definition: avformat.h:1038
This structure stores compressed data.
Definition: avcodec.h:898
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:52
#define MAX_STD_TIMEBASES
Stream information used internally by av_find_stream_info()
Definition: avformat.h:726
const struct AVCodecTag *const * codec_tag
Definition: avformat.h:478
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
Definition: avformat.h:713
struct AVPacketList * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
Definition: avformat.h:781
AVProgram ** programs
Definition: avformat.h:931