加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

【转】ffmpeg分析三重要结构体之AVFormatContext

(2016-07-06 17:01:31)
标签:

ffmpeg

avformatcontext

分类: 多媒体/FFMPEG/协议

ffmpeg重要结构体之AVFrame

ffmpeg重要结构体之AVFormatContext

ffmpeg重要结构体之AVCodecContext

ffmpeg重要结构体之AVCodec

ffmpeg重要结构体之AVIOContext

ffmpeg重要结构体之AVStream

ffmpeg重要结构体之AVPacket


结构体AVFormatContext位于文件libavformat/avformat.h中。是有关文件格式的结构体。

 

[cpp] view plain copy
  1. typedef struct AVFormatContext  
  2.       
  3.     const AVClass *av_class;  
  4.   
  5.       
  6.     struct AVInputFormat *iformat;  
  7.   
  8.       
  9.     struct AVOutputFormat *oformat;  
  10.   
  11.       
  12.     void *priv_data;  
  13.   
  14.       
  15.     AVIOContext *pb;  
  16.   
  17.       
  18.       
  19.     int ctx_flags;  
  20.   
  21.       
  22.     unsigned int nb_streams;  
  23.       
  24.     AVStream **streams;  
  25.   
  26.       
  27.     char filename[1024];  
  28.   
  29.       
  30.     int64_t start_time;  
  31.   
  32.       
  33.     int64_t duration;  
  34.   
  35.       
  36.     int64_t bit_rate;  
  37.   
  38.     unsigned int packet_size;  
  39.     int max_delay;  
  40.   
  41.       
  42.     int flags;  
  43. #define AVFMT_FLAG_GENPTS       0x0001 ///< Generate missing pts even if it requires parsing future frames.  
  44. #define AVFMT_FLAG_IGNIDX       0x0002 ///< Ignore index.  
  45. #define AVFMT_FLAG_NONBLOCK     0x0004 ///< Do not block when reading packets from input.  
  46. #define AVFMT_FLAG_IGNDTS       0x0008 ///< Ignore DTS on frames that contain both DTS PTS  
  47. #define AVFMT_FLAG_NOFILLIN     0x0010 ///< Do not infer any values from other values, just return what is stored in the container  
  48. #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  
  49. #define AVFMT_FLAG_NOBUFFER     0x0040 ///< Do not buffer frames when possible  
  50. #define AVFMT_FLAG_CUSTOM_IO    0x0080 ///< The caller has supplied custom AVIOContext, don't avio_close() it.  
  51. #define AVFMT_FLAG_DISCARD_CORRUPT  0x0100 ///< Discard frames marked corrupted  
  52. #define AVFMT_FLAG_FLUSH_PACKETS    0x0200 ///< Flush the AVIOContext every packet.  
  53.   
  54. #define AVFMT_FLAG_BITEXACT         0x0400  
  55. #define AVFMT_FLAG_MP4A_LATM    0x8000 ///< Enable RTP MP4A-LATM payload  
  56. #define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)  
  57. #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)  
  58. #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.  
  59. #define AVFMT_FLAG_FAST_SEEK   0x80000 ///< Enable fast, but inaccurate seeks for some formats  
  60.   
  61.       
  62.     int64_t probesize;  
  63.   
  64.       
  65.     int64_t max_analyze_duration;  
  66.   
  67.     const uint8_t *key;  
  68.     int keylen;  
  69.   
  70.     unsigned int nb_programs;  
  71.     AVProgram **programs;  
  72.   
  73.       
  74.     enum AVCodecID video_codec_id;  
  75.   
  76.       
  77.     enum AVCodecID audio_codec_id;  
  78.   
  79.       
  80.     enum AVCodecID subtitle_codec_id;  
  81.   
  82.       
  83.     unsigned int max_index_size;  
  84.   
  85.       
  86.     unsigned int max_picture_buffer;  
  87.   
  88.       
  89.     unsigned int nb_chapters;  
  90.     AVChapter **chapters;  
  91.   
  92.       
  93.     AVDictionary *metadata;  
  94.   
  95.       
  96.     int64_t start_time_realtime;  
  97.   
  98.       
  99.     int fps_probe_size;  
  100.   
  101.       
  102.     int error_recognition;  
  103.   
  104.       
  105.     AVIOInterruptCB interrupt_callback;  
  106.   
  107.       
  108.     int debug;  
  109. #define FF_FDEBUG_TS        0x0001  
  110.   
  111.       
  112.     int64_t max_interleave_delta;  
  113.   
  114.       
  115.     int strict_std_compliance;  
  116.   
  117.       
  118.     int event_flags;  
  119. #define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata.  
  120.   
  121.       
  122.     int max_ts_probe;  
  123.   
  124.       
  125.     int avoid_negative_ts;  
  126. #define AVFMT_AVOID_NEG_TS_AUTO             -1 ///< Enabled when required by target format  
  127. #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE ///< Shift timestamps so they are non negative  
  128. #define AVFMT_AVOID_NEG_TS_MAKE_ZERO         ///< Shift timestamps so that they start at 0  
  129.   
  130.       
  131.     int ts_id;  
  132.   
  133.       
  134.     int audio_preload;  
  135.   
  136.       
  137.     int max_chunk_duration;  
  138.   
  139.       
  140.     int max_chunk_size;  
  141.   
  142.       
  143.     int use_wallclock_as_timestamps;  
  144.   
  145.       
  146.     int avio_flags;  
  147.   
  148.       
  149.     enum AVDurationEstimationMethod duration_estimation_method;  
  150.   
  151.       
  152.     int64_t skip_initial_bytes;  
  153.   
  154.       
  155.     unsigned int correct_ts_overflow;  
  156.   
  157.       
  158.     int seek2any;  
  159.   
  160.       
  161.     int flush_packets;  
  162.   
  163.       
  164.     int probe_score;  
  165.   
  166.       
  167.     int format_probesize;  
  168.   
  169.       
  170.     char *codec_whitelist;  
  171.   
  172.       
  173.     char *format_whitelist;  
  174.   
  175.       
  176.     AVFormatInternal *internal;  
  177.   
  178.       
  179.     int io_repositioned;  
  180.   
  181.       
  182.     AVCodec *video_codec;  
  183.   
  184.       
  185.     AVCodec *audio_codec;  
  186.   
  187.       
  188.     AVCodec *subtitle_codec;  
  189.   
  190.       
  191.     AVCodec *data_codec;  
  192.   
  193.       
  194.     int metadata_header_padding;  
  195.   
  196.       
  197.     void *opaque;  
  198.   
  199.       
  200.     av_format_control_message control_message_cb;  
  201.   
  202.       
  203.     int64_t output_ts_offset;  
  204.   
  205.       
  206.     uint8_t *dump_separator;  
  207.   
  208.       
  209.     enum AVCodecID data_codec_id;  
  210.   
  211.       
  212.     int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options);  
  213. AVFormatContext;  
其中主要的成员:

 

struct AVInputFormat *iformat:输入文件的格式。解码某mp4文件如图:

http://img.blog.csdn.net/20151112155406515?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center

可从iformat中得到MP4格式的相关信息。

AVIOContext *pb:IO上下文结构体,这个以后详细介绍。

unsigned int nb_streams:文件中流的数量。(比如值为2,一个音频流,一个视频流)

AVStream **streams:流结构体。以后详细介绍。

char filename[1024]:文件名。

int64_t duration:流的持续时间,单位微秒?

int64_t bit_rate:比特率。单位bps

int64_t probesize:判断文件格式(format)需要读入的文件尺寸

int max_ts_probe:解码TS格式时,在得到第一个PTS前可解码的最大packet的数量。

int ts_id:TS格式中流的pid。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有