我正在AVFoundation
使用仅音频 - 即没有视频 - 并尝试将几个AVComposition
s 一个接一个地连接在一起,最终得到一个 s AVComposition
。
示例案例:只有两个AVComposition
s。他们每个人都通过创建一个 AVPlayer 玩得很好,因此:
_player = [AVPlayer playerWithPlayerItem:[AVPlayerItem playerItemWithAsset:comp]]
comp
的实例在哪里AVMutableComposition
。(顺便说一句,值得注意的是,它_player
必须是 ivar,否则 ARC 会在播放之前过早地释放它 - 需要一段时间才能找到它。)
这很好 - 执行
[_player play]
结果comp
播放成功。
但是,这失败了:
(self.segments
是一个NSMutableArray
包含元素的自定义子类AVMutableComposition
)
AVMutableComposition *comp = [AVMutableComposition composition];
NSError *err;
for (AVMutableComposition* c in self.segments) {
[comp insertTimeRange:CMTimeRangeMake(kCMTimeZero, segment.duration)
ofAsset:segment atTime:comp.duration error:&err];
DLog(@"Error was %@", segment, err);
}
对于self.segments
此代码执行时的每个元素,我在调用该insertTimeRange::::
方法时都会收到此错误:
Error was Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not
be completed" UserInfo=0x14e8e7f0 {NSLocalizedDescription=The operation could not be
completed, NSUnderlyingError=0x14d7f580 "The operation couldn’t be completed. (OSStatus
error -12780.)", NSLocalizedFailureReason=An unknown error occurred (-12780)}
我找不到有关此错误指示的任何信息 - 似乎只是一个包罗万象的信息 - 我看不出我做错了什么。有任何想法吗?