AVMutableCompositionTrack - insertTimeRange - insertEmptyTimeRange issue

守給你的承諾、 提交于 2019-12-01 05:38:36

Still don't know what this "insertEmptyTimeRange" means. I made a work around with a "silence"-audio file which has nothing in it. I put this empty audio file between the two sound files and this does it for me. Question closed ;) (But if someone could explain this "insertEmptyTimeRange" this would be still interesting...)

I got it working as follows:

[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, CMTimeMake(2,1))
                               ofTrack:audioTrack
                                atTime:kCMTimeZero
                                error:nil];
[compositionAudioTrack insertEmptyTimeRange:CMTimeRangeMake(CMTimeMake(2, 1), CMTimeMake(4, 1))];
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, CMTimeMake(2,1))  
                               ofTrack:audioTrack 
                                atTime:CMTimeMake(4, 1)
                                 error:nil];

The "empty time range" needs to be (2,4) if your sounds are from (0,2) and (4,6).

Not sure if its late,

insertEmptyTimeRange : If you insert an empty time range into the track, any media that was presented during that interval prior to the insertion will be presented instead immediately afterward.

So all you have to do is add both the clips first and then add the emptytime range at time 2. This should work

insertTimeRange(0 to 2)
insertTimeRange(2 to 4)
insertEmptyTimeRange(2 to 4)

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