AVAssetWriter的输出(写入视频的UIImages)失真 [英] Output from AVAssetWriter (UIImages written to video) distorted

查看:289
本文介绍了AVAssetWriter的输出(写入视频的UIImages)失真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AVAssetWriter将一系列图像编码为电影文件,遵循Zoul的回答:如何将UIImage数组导出为电影?

I am using an AVAssetWriter to encode a series of images to a movie file, following Zoul's answer here: How do I export UIImage array as a movie?.

简而言之,我的流程是:

In short my process is:


  • 从.png文件创建UIImage

  • 从UIImage获取CGImage

  • 将CGImage转换为CVPixelBuffer(完全使用zoul的函数pixelBufferFromCGImage)

  • 写使用AVAssetWriterInputPixelBufferAdaptor和AVAssetWriter的.mov的帧

  • create UIImage from .png file
  • Get CGImage from UIImage
  • convert the CGImage to CVPixelBuffer (using zoul's function pixelBufferFromCGImage exactly)
  • write the frames to .mov using a AVAssetWriterInputPixelBufferAdaptor and AVAssetWriter

这在大多数情况下工作正常,但有时编码的.mov文件是扭曲(见下图)。我想知道这种类型的失真图像输出是否为任何人都熟悉,如果有任何步骤我可能会采用编码导致这种情况的帧。当我使用的源图像是通过Titanium中的调用生成到ImageView.toBlob()时,会出现问题。除了Titanium方面,任何关于如何出现这种结果的提示都会很棒!

This is working fine in most cases, however sometimes the .mov file that is encoded is distorted (see picture below). I was wondering if this type of distorted image output is familiar to to anyone, and if there is any step I might have taken in encoding the frames that would cause this. The problem occurs specifically when the source images I use are generated by calls in Titanium to ImageView.toBlob(). Besides the Titanium side, any hints on how this type of result might appear would be great!

谢谢,
Alexander

Thanks, Alexander

电影画面:
http:// tinypic.com/view.php?pic=8wkqys&s=7

原始图片: http://commons.wikimedia.org/wiki/File:Phalaenopsis_( aka)jpg

推荐答案

好吧,原来这是我正在阅读的图像的宽高比与我正在创建的PixelBuffer的宽高比不同的问题。使它们相等,它工作正常。

Ok, this turned out to be an issue with the aspect ratio of the images I was reading in being different from the aspect ratio of the PixelBuffer I was creating. Made them equal and it works fine.

这篇关于AVAssetWriter的输出(写入视频的UIImages)失真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆