ios录制视频长度超过10s,没有声音的解决方法

转载自:http://blog.csdn.net/wxlemon/article/details/50445338
使用AVCaptureSession录制视频和音频。如果是短时间的视频录制,完全没有问题。但是出于某种原因,如果我录制超过10秒的视频,就会没有音频。这个问题困扰了很久。
最终发现。
这个问题是AVCaptureMovieFileOutput movieFragmentInterval属性。

/*!
 @property movieFragmentInterval
 @abstract
    Specifies the frequency with which movie fragments should be written.
 
 @discussion
    When movie fragments are used, a partially written QuickTime movie file whose writing is unexpectedly interrupted can be successfully opened and played up to multiples of the specified time interval. A value of kCMTimeInvalid indicates that movie fragments should not be used, but that only a movie atom describing all of the media in the file should be written. The default value of this property is ten seconds.
 
    Changing the value of this property will not affect the movie fragment interval of the file currently being written, if there is one.
 */

可以看出,它的默认值就是10秒。将这个值禁用后。
_captureMovieFileOutput.movieFragmentInterval = kCMTimeInvalid;
问题得到了圆满解决。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容