Why does my movie from UIImages gets distorted?

前端 未结 3 1498
星月不相逢
星月不相逢 2020-12-14 03:52

I\'m using zoul\'s solution to export UIImage array as a movie. But my frames all turns out distorted. Here\'s the original image:

Here\'s a similar distor

相关标签:
3条回答
  • 2020-12-14 04:31

    After a lot of experiments with different image sizes, and with the help of this article, I've got to the conclusion that the width of the images must be a multiple of 16.

    0 讨论(0)
  • 2020-12-14 04:39

    I'v encountered this problem too, and I found the reason is the image's size is not the multiple of 16, you can change the size and have a try.

    0 讨论(0)
  • 2020-12-14 04:47

    For those still doing the journey in 2020, and getting distortion in their movies because its not width 16px

    change

    CGContextRef context = CGBitmapContextCreate(pxdata,
                                                 width, height,
                                                 8, 4 * width,
                                                 rgbColorSpace,
                                                 kCGImageAlphaNoneSkipFirst);
    

    to

    CGContextRef context = CGBitmapContextCreate(pxdata,
                                                 width, height,
                                                 8, CVPixelBufferGetBytesPerRow(pxbuffer),
                                                 rgbColorSpace,
                                                 kCGImageAlphaNoneSkipFirst);
    

    Credit to @Bluedays Output from AVAssetWriter (UIImages written to video) distorted

    0 讨论(0)
提交回复
热议问题