[Libav-user] iOS: Converting AVFrame to UIImage
Gary Overall
goverall at hotmail.com
Wed Apr 17 04:15:06 CEST 2013
I am working on an iOS app and have been researching and seen different approaches of converting video frames from sws_scale() to a UIImage, for placement in a UIImageView. I am presently attempting to play my video by successively altering the contents of my UIImageView. I retrieve a frame like this:
AVFrame *pFrame;
AVFrame *pFrameRGB = NULL;
// allocate a video frame
pFrame=avcodec_alloc_frame();
// Allocate an AVFrame structure
pFrameRGB=avcodec_alloc_frame();
sws_ctx =
sws_getContext
(
pCodecCtx->width,
pCodecCtx->height,
pCodecCtx->pix_fmt,
pCodecCtx->width,
pCodecCtx->height,
PIX_FMT_RGB24,
SWS_BILINEAR,
NULL,
NULL,
NULL
);
/* In a loop I do this */ len=avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,&packet);
if(frameFinished) {
// Convert the image from its native format to RGB
sws_scale(sws_ctx,(uint8_t const * const *)pFrame->data,pFrame->linesize,0,pCodecCtx->height,pFrameRGB->data,pFrameRGB->linesize);
I then want to take pFrame and convert it to a UIImage so that I can update the UIImageView.Can someone please point me in a really good direction of how to do this conversion?
Thank You In Advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130416/003068b3/attachment.html>
More information about the Libav-user
mailing list