I am creating an application in which we can able to draw using our finger in an imageView , the same time we can record the screen also. I have done these features so far , but the problem is once the video recording is completed , if we play the recorded video the finger drawing is not smooth in video.
I am not using opengl , the drawing is on UIImageView and on every 0.01 sec we capture th image from UIImageView and append the pixel buffer to the AVAssetWriterInputPixelBufferAdaptor object .
Here is the code I used for converting the UIImage into buffer
- (CVPixelBufferRef) pixelBufferFromCGImage:(CGImageRef) image {
CGSize frameSize = CGSizeMake(976, 667);
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,
[NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey,
nil];
CVPixelBufferRef pxbuffer = NULL;
CVPixelBufferCreate(kCFAllocatorDefault, frameSize.width,
frameSize.height, kCVPixelFormatType_32ARGB, (__bridge CFDictionaryRef) options,
&pxbuffer);
CVPixelBufferLockBaseAddress(pxbuffer, 0);
void *pxdata = CVPixelBufferGetBaseAddress(pxbuffer);
CGColorSpaceRef rgbColorSpace = CGImageGetColorSpace(image);
CGContextRef context = CGBitmapContextCreate(pxdata, frameSize.width,
frameSize.height, 8, 4*frameSize.width, rgbColorSpace,
kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image),
CGImageGetHeight(image)), image);
CGContextRelease(context);
CVPixelBufferUnlockBaseAddress(pxbuffer, 0);
return pxbuffer;
}
the below method is calling on 0.01 sec timeinterval
CVPixelBufferRef pixelBufferX = (CVPixelBufferRef)[self pixelBufferFromCGImage:theIM];
bValue = [self.avAdaptor appendPixelBuffer:pixelBufferX withPresentationTime:presentTime];
Can any one guide for the improvement in video capture ?
Thanks in advance