ios - 录制视频的时候,视频长度超过10s,没有声音的解决方案
PHP中文网
PHP中文网 2017-04-17 15:15:46
[iOS讨论组]

  我使用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
问题得到了圆满解决。

希望能帮助和我一样,因为这个苦苦搜寻的同学们。

PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号