</pre>直接贴代码!AVFormatContext<pre name="code" class="cpp">typedef struct AVFormatContext {
/*
AVFormatContext包含码流参数较多。主要储存音视频封装格式中的信息
*/
const AVClass *av_class;
//下面二者只能出现一个,不能同时出现
//解码时下面两项由avformat_open_input()来确定
//编码时由用户来决定
struct AVInputFormat *iformat;
struct AVOutputFormat *oformat;
//私有格式数据,这是一个能被--enable选择的类型
//当且仅当iformat或者oformat存在时,priv_data不为空
void *priv_data;
//I/O内容,输入数据的缓存
//解码时在avformt_open_input()之前由用户设定(用户也得手动的关闭)
//编码时也是由用户来指定
//当AVFMT_NOFILE的flag在iformat/oformat.flag中被设定的时候,
//此项为空。在这种情况下,(解)复用器将会处理
//在某些情况,此段也会为空。
AVIOContext *pb;
//特别的格式标志,如:AVFMTCTX_XX
int ctx_flags;
//文件中码流表,又avformat_new_stream来建立
//解码时,stream由libavformat的avformat_open_input()函数来建立
//出现av_read_frame()中
//编码时,streams由用户在avformat+write+header()来建立
unsigned int nb_streams;//视音频流的个数
AVStream **streams;//视音频流(重要)
char filename[1024];//输入或者输出的filename
//解码时,第一帧位置,在AV_TIME_BASE的小数秒钟。
//永远不要直接的来设置start_time的值。
//它是由AVStream的值来推断出来的
int64_t start_time;
//解码时,stream的持续时间在AV_TIME_BASE的小数位
//只有在知道没有任何stream持续时间且没对他们做任何设置的时候
//才对duration赋值
int64_t duration;
//解码时,整个stream的比特率,如果时available,其为0.
//不要直接设置它的值,因为如果文件大小和持续时间是已知的,
//FFmpeg会自动计算它。
int bit_rate;
unsigned int packet_size;
int max_delay;
int flags;
#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
#define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible
#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
#define AVFMT_FLAG_FLUSH_PACKETS 0x0200 ///< Flush the AVIOContext every packet.
#define AVFMT_FLAG_BITEXACT 0x0400
#define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload
#define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.
#define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats
#if FF_API_PROBESIZE_32
//解码时,probe的数据大小,解码时不会用到此项
unsigned int probesize;
attribute_deprecated
//解码时,在最大时间(在AV_TIME_BASE里)内
//输入被avformat_find_stream_info()解析
int max_analyze_duration;
#endif
const uint8_t *key;
int keylen;
unsigned int nb_programs;
AVProgram **programs;
//音视频的编解码器ID
//解复用时:由用户指定
enum AVCodecID video_codec_id;
enum AVCodecID audio_codec_id;
enum AVCodecID subtitle_codec_id;
//最大的bytes用于stream的索引,如果超过这个大小,入口将会拒绝
//需要分配一个更小的大小,这可能会导致更慢或者更加不精准的搜索(决定与解复用器)
//muxing:不用此项
//demuxing:用户指定
unsigned int max_index_size;
//最大的bytes用于由实时捕获设备的帧缓存。
unsigned int max_picture_buffer;
unsigned int nb_chapters;
AVChapter **chapters;
AVDictionary *metadata;//元数据
//stream的实际时间,此时pts=0.
//解码时,不用
//编码时:由用户指定
int64_t start_time_realtime;
int fps_probe_size;
int error_recognition;
AVIOInterruptCB interrupt_callback;
int debug;
#define FF_FDEBUG_TS 0x0001
int64_t max_interleave_delta;
int strict_std_compliance;
int event_flags;
#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata.
int max_ts_probe;
int avoid_negative_ts;
#define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format
#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
#define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0
//变换的stream id
int ts_id;
//音频的预载,时间单位位微秒
int audio_preload;
//最大的块时间,微秒
//并不是所有的格式都支持
int max_chunk_duration;
//最大的块大小,bytes
int max_chunk_size;
int use_wallclock_as_timestamps;
int avio_flags;
enum AVDurationEstimationMethod duration_estimation_method;
int64_t skip_initial_bytes;
unsigned int correct_ts_overflow;
int seek2any;
int flush_packets;
int probe_score;
int format_probesize;
char *codec_whitelist;
char *format_whitelist;
AVFormatInternal *internal;
int io_repositioned;
AVCodec *video_codec;
AVCodec *audio_codec;
AVCodec *subtitle_codec;
AVCodec *data_codec;
int metadata_header_padding;
void *opaque;
av_format_control_message control_message_cb;
//输出时的时间戳便宜,微秒
//不能直接设置
int64_t output_ts_offset;
#if FF_API_PROBESIZE_32
int64_t max_analyze_duration2;
#else
int64_t max_analyze_duration;
#endif
#if FF_API_PROBESIZE_32
int64_t probesize2;
#else
int64_t probesize;
#endif
uint8_t *dump_separator;
enum AVCodecID data_codec_id;
int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options);
} AVFormatContext;
转载请注明,谢谢!