版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
SDK之快速本節(jié)主要介紹ffmpeg框架,熟悉ffmpegFFMPEGOGG、Matroska、ASF90TCPMP,VLC, .FFmpeg 下主要有l(wèi)ibavcodec、libavformat和libavutil等 .c和h263de.c AVInputFormatencoderdecoderAVCodec結構。muxer/demuxerencoder/decoderFFmpeg中相同的地方有: AVInputFormat*first_iformatencoder/decoderAVCodec*first_avcodec int(*read_probe)(AVProbeDataint(*read_header)(structAVFormatContext*,int(*read_packet)(structAVFormatContext*,AVPacketint(*read_close)(structAVFormatContextint(*read_seek)(structAVFormatContext*,intstream_index,int64_ttimestamp,intflags);int(*write_header)(structAVFormatContextint(*write_packet)(structAVFormatContext*,int(*write_trailer)(structAVFormatContextint(*init)(AVCodecContextint(*encode)(AVCodecContext*,uint8_t*buf,intbuf_size,void*data);int(*close)(AVCodecContextint(*decode)(AVCodecContext*,void*outdata,*outdata_size,uint8_t*buf,intREGISTER_MUXDEMUX(FLV, first_oformat與first_iformat鏈表的最后位置。AVOutputFormatflv_muxer={"flvformat", #else//CONFIG_LIBMP3LAME.codec_tag=(constAVCodecTag*[]){flv__codec_ids,flv_audio_codec_ids,0},}typedefstructAVOutputFormat{constchar*name;
constchar*long_name;constcharconstchar*extensions;/**<commaseparatedfilenameextensions/**sizeofprivatedatasothatitcanbeallocatedintheint/*outputsupportenumCodecIDaudio_codec;/**<defaultaudiocodec*/enumCodecID_codec;/**<defaultcodec*/int(*write_header)(structAVFormatContext*);int(*write_packet)(structAVFormatContext*,AVPacket*pkt);int(*write_trailer)(structAVFormatContext*);/**canuseflags:AVFMT_NOFILE,AVFMT_NEEDNUMBER,int/**currentlyonlyusedtosetpixelformatifnotYUV420Pint(*set_parameters)(structAVFormatContext*,int(*interleave_packet)(structAVFormatContext*,AVPacketAVPacket*in,intlistofsupportedcodec_id-codec_tagpairs,orderedby"betterchoicefirst"thearraysareallCODEC_ID_NONEconststructAVCodecTag/*privatefieldsstructAVOutputFormat}頻編碼和編碼類型ID,muxer是否是符合當前文件格式,這個接口在匹配當前demuxer的時候會用到。AVInputFormatflv_demuxer={.extensions=.value=里的avcodec_register_all(void)函數(shù)來初始化全部的encoder/decoder。因為不是每種編碼方式都支持encode和decode,所以有以下三種 #defineREGISTER_ENCODER(X,x)\#defineREGISTER_DECODER(X,x)\#defineREGISTER_ENCDEC(X,x)flvflv_encoderflv_decoder 當前muxer/demuxer名匹配合適的demuxer和muxer。file_iformat和file_oformat中:staticAVInputFormat*file_iformat;staticAVOutputFormat*file_oformat; libavformat\utils.cstatic行該demuxer是否和傳入的文件內容匹配的判斷。其調用順序如下:voidparse_options(intargc,char**argv,constOptionDef*options)staticvoidopt_input_file(constchar*filename)staticvoidopt_input_file(constcharintav_open_input_file(??*av_probe_input_format(AVProbeData*pd,intstaticstaticAVInputFormatparse_options(intargc,char**argv,constOptionDef argvvoidparse_options(intargc,char**argv,constOptionDef*options)voidparse_arg_file(constchar*filename)staticvoidopt_output_file(constchar*filename)AVOutputFormat*guess_format(constchar*short_name,constcharconstchar當前encoder/decodermain()函數(shù)中除了解析傳入參數(shù)并初始化demuxermuxer在libavcodec\utils.c中有如下二個函數(shù)。AVCodec*avcodec_find_encoder(enumCodecIDid)AVCodec*avcodec_find_decoder(enumCodecIDav_encode()函數(shù)的開頭,首先初始化各個AVInputStream和AVInputStream->AVStream*st->AVCodecContext*codec->struct*codecAVOutputStream->AVStream*st-*codec->structAVCodec*codecstaticAVFormatContext*output_files[MAX_FILES];staticAVFormatContext*input_files[MAX_FILES];iformatoformatstructAVInputFormat*iformat;structAVOutputFormat*oformat;demuxermuxerenumCodecTypecodec_type;/*seeCODEC_TYPE_xxx*/enumCodecIDcodec_id;/*seeCODEC_ID_xxx如上所示,codec_type保存的是CODEC_TYPE_ 以支持flv格式為例, 述的av_open_input_file(??)函數(shù)中,匹配到正確的AVInputFormatdemuxer后,通過av_open_input_stream()函數(shù)中調用AVInputFormat的read_header接口來執(zhí)行flvdec.c中的值。codec_id值是 過程中flv_read_packet()函數(shù)執(zhí)行時根據(jù)每一AVCodecContext*codec;/**<codeccontextvoidASF的過程中,priv_data保存的就是ASFStream結構的數(shù)據(jù)。AVStreamASFStreamASFStreamst->priv_data=AVOutputStream結構中,在av_encode()函數(shù)中使用。AVInputStream中還保存的有與時間有關的信息。AVOutputStream中還保存有與音 typedefstructAVPacketint64_tuint8_t///<presentationtimestampinpressiontimestampin (0ifnotavailable)void(*destruct)(structAVPacket*);void*priv;int64_t ///<bytepositioninstream,-1if}av_encode(AVInputFormatAVFormatContext*,AVPacket*pkt);接口, 當前輸入AVFormatContext的AVPacket成員中。inputstreamsoutputstreamsencodersand
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 美容院前臺服務員工作總結
- 家居建材行業(yè)營銷工作總結
- 二零二五年度二手車交易個人信用貸款合作協(xié)議3篇
- 二零二五版消費信貸合同參考范本3篇
- 二零二五版小產權房屋交易協(xié)議(附裝修及配套設施承諾)6篇
- 2025版淘寶商家與消費者金融支付合同3篇
- 二零二五年度汽車租賃及維修一體化服務協(xié)議4篇
- 2025版石榴品牌授權與市場推廣合作協(xié)議3篇
- 二零二五年度個人消費貸款合同個人信息保護條款3篇
- 二零二五年度綠色蔬菜直供社區(qū)配送合同2篇
- 安全生產法律法規(guī)匯編(2025版)
- 2024年英語高考全國各地完形填空試題及解析
- 2024至2030年中國餐飲管理及無線自助點單系統(tǒng)數(shù)據(jù)監(jiān)測研究報告
- 2024年服裝門店批發(fā)管理系統(tǒng)軟件項目可行性研究報告
- 體育概論(第二版)課件第三章體育目的
- T-GDASE 0042-2024 固定式液壓升降裝置安全技術規(guī)范
- 香港朗文4B單詞及句子
- 運動技能學習與控制課件第五章運動中的中樞控制
- 財務部規(guī)范化管理 流程圖
- 斷絕關系協(xié)議書范文參考(5篇)
- 農村集體“三資”管理流程圖
評論
0/150
提交評論