Hi Apple support,
I'm writing a video exporting app. I created an AVAssetWriterInputPixelBufferAdaptor with these options
NSDictionary *options = @{(NSString *)kCVPixelBufferWidthKey: @(ceil(size.width / 16) * 16),
(NSString *)kCVPixelBufferHeightKey: @(ceil(size.height / 16) * 16),
(NSString *)kCVPixelBufferCGImageCompatibilityKey: @(YES),
(NSString *)kCVPixelBufferCGBitmapContextCompatibilityKey: @(YES),
(NSString *)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA)
};
next, I programmticly created each frame from a CGImage and draw into a CGContextRef backed by CVPixelBufferRef. And append it to the AVAssetWriterInputPixelBufferAdaptor
CGContextRef context = CGBitmapContextCreate(pxdata, width, height, bPerComponent, b64PerRow, colorSpace, kCGBitmapByteOrder32Little | info);
NSParameterAssert(context);
For reason unknown to me and it seem and only on iPhone Xs. I need to align the bytesPerRow to some multiple of 64. Otherwise, it will create stripy pattern in the output video. However, I don't need to do this for iPhone 8 or 6!!! I have not tested on iPhone X.
ONLY on iPhone Xs as far as I can tell.
long b64PerRow = (bytesPerRow/64 + 1) * 64;
iPhone 6 & 8:
size_t bytesPerRow = CGImageGetBytesPerRow(image);
How do I know when to align to multiple of 64?
iPhone Xs without alignment: https://i.imgur.com/ICA5I9p.jpg
iPhone 6 without alignment: https://i.imgur.com/RE3XwO0.png