FFMpeg分析3:AVFormatContext和AVIContext、FLVContext等XXXContext

來源:互聯網
上載者:User

     AVFormatContext在FFMpeg裡是一個非常重要的的結構,是其它輸入、輸出相關資訊的一個容器,需要注意的是其中兩個成員:

  struct AVInputFormat *iformat;//資料輸入格式  struct AVOutputFormat *oformat;//資料輸出格式這兩個成員不能同時賦值,即AVFormatContext不能同時做為輸入、輸出格式的容器。AVFormatContext和AVIContext、FLVContext等XXXContext之間像前面講的URLContext和URLProtocol的關係一樣,是一種"多態"關係,即AVFormatContext對像記錄著運行時大家共有的資訊,而各個XXXContext記錄自己檔案格式的資訊,如AVIContext、FLVContext等。AVInputFormat->priv_data_size記錄相對應的XXXContext的大小,該值大小在編譯時間靜態確定。AVFormatContext的void *priv_data記錄XXXContext指標。AVFormatContext對像的初始化主要在AVInputFormat的read_header函數中進行,read_header是個函數指標,指向具體的檔案類型的read_header,如flv_read_header(),avi_read_header()等,AVFormatContext、AVInputFormat和XXXContext組成一起共同完成資料輸入模組,可以出來粗魯的認為,AVFormatContext是一個類容器,AVInputFormat是這個類的操作函數集合,XXXContext代表該類的私人資料對像。AVFormatContext還有個重要的成員 AVStream *streams[MAX_STREAMS];也是在read_header裡初始化,這個等會兒再講。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.