Video Encoding using AVAssetWriter - CRASHES

霸气de小男生 提交于 2019-11-27 18:24:00

-copyNextSampleBuffer is returning a CMSampleBufferRef with +1 retain (copy methods do that). This means you must release the object. Since you're not doing so, you're going to leak a copy every pass through your while() loop.

Additionally, you're running that loop tightly without managing an autorelease pool. If there are objects being autoreleased in any of the routines you're calling, they will not be released until the autorelease pool above you drains. Since your while() loop duration is based on input, it's a good candidate for adding a manual autorelease pool.

One other thing to consider: because you're running this synchronously with a while() loop, you'll block the thread and possibly spin unnecessarily over your continue condition several times. AVAssetWriterInput provides an alternative mechanism to use libdispatch to process data asynchronously as resources become available: -requestMediaDataWhenReadyOnQueue:usingBlock:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!