各種控件實現(xiàn)code ffmpeg框架代碼閱讀_第1頁
各種控件實現(xiàn)code ffmpeg框架代碼閱讀_第2頁
各種控件實現(xiàn)code ffmpeg框架代碼閱讀_第3頁
各種控件實現(xiàn)code ffmpeg框架代碼閱讀_第4頁
各種控件實現(xiàn)code ffmpeg框架代碼閱讀_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論