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

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

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

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值