[Libav-user] iOS: Converting AVFrame to UIImage

Gavin Kinsey gkinsey at ad-holdings.co.uk
Thu Apr 18 16:45:59 CEST 2013


On Wednesday 17 April 2013 03:15:06 Gary Overall wrote:
> 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 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


Create a CGImage from the data then a UIImage from that

        CFDataRef cfdata = CFDataCreate(NULL, frameBuf, size);
        CGDataProviderRef dataProv = CGDataProviderCreateWithCFData(cfdata);
        
        CGImageRef cfimg = CGImageCreate(w, 
                                         h, 
                                         bitsPerComponent, 
                                         bitDepth, 
                                         w * bytesPP, 
                                         rgbColour, bmpInfo, dataProv, 
                                         NULL, 
                                         NO, 
                                         kCGRenderingIntentDefault);

        [self setImage: [UIImage imageWithCGImage:cfimg]];
        
        CGImageRelease(cfimg);
        CGDataProviderRelease(dataProv);
        CFRelease(cfdata);

Something like that.

-- 
Gavin Kinsey
AD Holdings Plc


--------------------------------------------------------
This email and any files transmitted with it are CONFIDENTIAL and intended solely for the use of the individual or entity to whom they are addressed. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system; you may not copy this message or disclose its contents to anyone. The recipient should check this email and any attachments for the presence of viruses. The Company accepts no liability for any damage caused by any virus transmitted by this email. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the Company. Contact Customer Services for details customerservices at dmicros.com


More information about the Libav-user mailing list