会ffmpeg 的请进!!
while(av_read_frame(pDlg->pFormatCtx, &pDlg->packet) >= 0) { // Is this a packet from the video stream? if(pDlg->packet.stream_index == pDlg->videoStream) { // Decode video frame avcodec_decode_video(pDlg->pCodecCtx, pDlg->pFrame, &pDlg->frameFinished, pDlg->packet.data, pDlg->packet.size); // Did we get a video frame? if(pDlg->frameFinished) { AVPicture pict; // Convert the image from its native format to RGB struct SwsContext *img_convert_ctx; img_convert_ctx = sws_getContext(pDlg->pCodecCtx->width,pDlg->pCodecCtx->height, pDlg->pCodecCtx->pix_fmt, pDlg->pCodecCtx->width,pDlg->pCodecCtx->height,PIX_FMT_YUVJ420P,SWS_BICUBIC, NULL,NULL,NULL); if(img_convert_ctx == NULL) { fprintf(stderr, "Cannot initialize the conversion context!\n"); getchar(); } // 将图片转换为RGB格式 sws_scale(img_convert_ctx,pDlg->pFrame->data,pDlg->pFrame->linesize,0, pDlg->pCodecCtx->height,pict.data,pict.linesize); //pDlg->ShowVido(RGBbuf); Sleep(50); } } // Free the packet that was allocated by av_read_frame av_free_packet(&pDlg->packet); }