ffmpeg的解码流程内容摘要:

(pCodecCtxcodec_id)。 if(pCodec==NULL) { fprintf(stderr, Unsupported codec!\n)。 return 1。 // Codec not found } // Open codec if(avcodec_open(pCodecCtx, pCodec)0) return 1。 // Could not open codec // Allocate video frame pFrame=avcodec_alloc_frame()。 // Allocate an AVFrame structure pFrameRGB=avcodec_alloc_frame()。 if(pFrameRGB==NULL) return 1。 // Determine required buffer size and allocate buffer numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtxwidth, pCodecCtxheight)。 buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t))。 // Assign appropriate parts of buffer to image planes in pFrameRGB // Note that pFrameRGB is an AVFrame, but AVFrame is a superset // of AVPicture avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24, pCodecCtxwidth, pCodecCtxheight)。 // Read frames and save first five frames to disk [4] i=0。 while(av_read_frame(pFormatCtx, amp。 packet)=0) { // Is this a packet from the video stream? if(==videoStream) { // Decode video frame avcodec_decode_video(pCodecCtx, pFrame, amp。 frameFinished, , )。 // Did we get a video frame? if(frameFinished) { // Convert the image from its native format to RGB img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24, (AVPicture*)pFrame, pCodecCtxpix_fmt, pCodecCtx。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。