【正文】
ters *ap){if (!fmt) {我們來看看如何獲取Packet,又如何從Packet中解碼frame的。......av_free(pFrameRGB)。i)。// Did we get a video frame?if(==videoStream) {packet)=0) {[4]pCodecCtxwidth, pCodecCtxheight)。numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtxwidth,// Allocate an AVFrame structure // Could not open codecpCodec=avcodec_find_decoder(pCodecCtxcodec_id)。// Get a pointer to the codec context for the video streambreak。// Find the first video streampFormatCtx, argv[1], NULL, 0, NULL)!=0)return 1。numBytes。frameFinished。packet。AVPacketAVFrame y++)if(pFile==NULL)sprintf(szFilename, frame%, iFrame)。char szFilename[32]。FFMpeg的解碼流程(20090618 14:50:32)標(biāo)簽:雜談 fprintf(pFile, P6\n%d %d\n255\n, width, height)。fclose(pFile)。*pCodecCtx。*pFrame。[1]// Retrieve stream informationif(av_find_stream_info(pFormatCtx)0)videoStream=i。// Open codecreturn 1。// Assign appropriate parts of buffer to image planes in pFrameRGB// Free the packet that was allocated by av_read_frame}av_close_input_file(pFormatCtx)。從文件中讀取packet,從Packet中解碼相應(yīng)的frame。||avcodec_decode_video()解復(fù)用av_read_frame()do something()。if(解碼幀完成)+