</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;
轉載請註明,謝謝!