【正文】
因此,在上面的代碼實(shí)際上是這樣的:從文件中讀取packet,從Packet中解碼相應(yīng)的frame。av_read_frame|+av_read_frame_internal|+av_parser_parse調(diào)用的是指定解碼器的sparserparser_parse函數(shù)以從raw packet中重構(gòu)frameavcodec_decode_video|+avctxcodecdecode調(diào)用指定Codec的解碼函數(shù)avcodec_decode_video()|解復(fù)用av_read_frame()因此,從上面的過程可以看到,實(shí)際上分為了兩部分:一部分是解復(fù)用(demuxer),然后是解碼(decode)使用的分別是:av_open_input_file()do something()。if(解碼幀完成)+av_open_input_stream調(diào)用指定demuxer的read_header函數(shù)以獲取相關(guān)|調(diào)用相應(yīng)的probe函數(shù)}[1]:沒什么太多好說的,如果不明白,看我轉(zhuǎn)載的關(guān)于FFmepg框架的文章[2]:先說說里面的AVFormatContext *pFormatCtx結(jié)構(gòu),字面意思理解AVFormatContext就是關(guān)于AVFormat(其實(shí)就是我們上面說的Container格式)的所處的Context(場景),自然是保存Container信息的總控結(jié)構(gòu)了,后面你也可以看到,基本上所有的信息,都可以從它出發(fā)而獲取到我們來看看av_open_input_file()都做了些什么:[libavformat/]int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,// Close the video file// Free the RGB image}}while(av_read_frame(pFormatCtx, amp。avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,// Note that pFrameRGB is an AVFrame, but AVFrame is a superset// Allocate video framereturn 1。if(avcodec_open(pCodecCtx, pCodec)0)}fprintf(stderr, Unsupported codec!\n)。if(pCodec==