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

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

SDK之快速本節(jié)主要介紹ffmpeg框架,熟悉ffmpegFFMPEGOGG、Matroska、ASF90TCPMP,VLC, .FFmpeg 下主要有l(wèi)ibavcodec、libavformat和libavutil等 .c和h263de.c AVInputFormatencoderdecoderAVCodec結(jié)構(gòu)。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}頻編碼和編碼類(lèi)型ID,muxer是否是符合當(dāng)前文件格式,這個(gè)接口在匹配當(dāng)前demuxer的時(shí)候會(huì)用到。AVInputFormatflv_demuxer={.extensions=.value=里的avcodec_register_all(void)函數(shù)來(lái)初始化全部的encoder/decoder。因?yàn)椴皇敲糠N編碼方式都支持encode和decode,所以有以下三種 #defineREGISTER_ENCODER(X,x)\#defineREGISTER_DECODER(X,x)\#defineREGISTER_ENCDEC(X,x)flvflv_encoderflv_decoder 當(dāng)前muxer/demuxer名匹配合適的demuxer和muxer。file_iformat和file_oformat中:staticAVInputFormat*file_iformat;staticAVOutputFormat*file_oformat; libavformat\utils.cstatic行該demuxer是否和傳入的文件內(nèi)容匹配的判斷。其調(diào)用順序如下: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當(dāng)前encoder/decodermain()函數(shù)中除了解析傳入?yún)?shù)并初始化demuxermuxer在libavcodec\utils.c中有如下二個(gè)函數(shù)。AVCodec*avcodec_find_encoder(enumCodecIDid)AVCodec*avcodec_find_decoder(enumCodecIDav_encode()函數(shù)的開(kāi)頭,首先初始化各個(gè)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后,通過(guò)av_open_input_stream()函數(shù)中調(diào)用AVInputFormat的read_header接口來(lái)執(zhí)行flvdec.c中的值。codec_id值是 過(guò)程中flv_read_packet()函數(shù)執(zhí)行時(shí)根據(jù)每一AVCodecContext*codec;/**<codeccontextvoidASF的過(guò)程中,priv_data保存的就是ASFStream結(jié)構(gòu)的數(shù)據(jù)。AVStreamASFStreamASFStreamst->priv_data=AVOutputStream結(jié)構(gòu)中,在av_encode()函數(shù)中使用。AVInputStream中還保存的有與時(shí)間有關(guān)的信息。AVOutputStream中還保存有與音 typedefstructAVPacketint64_tuint8_t///<presentationtimestampinpressiontimestampin (0ifnotavailable)void(*destruct)(structAVPacket*);void*priv;int64_t ///<bytepositioninstream,-1if}av_encode(AVInputFormatAVFormatContext*,AVPacket*pkt);接口, 當(dāng)前輸入AVFormatContext的AVPacket成員中。inputstreamsoutputstreamsencodersand

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論