iOS 9 : AVFoundation Export Session is missing audio

情到浓时终转凉″ 提交于 2019-12-06 16:02:21

Found the issue: I have used the below after the above code. After removing this it worked fine. The below extra line removes the already added audio track in iOS 9. Hope it helps someone!

AVMutableCompositionTrack *compositionAudioTrack2 = [videoComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];

I have had a similar problem, but my observation is that you can not add an audio track with no audio anymore. IOS 9 will then remove the complete audio.

So only this line will remove all audio 
compositionAudioTrack = [videoComposition 
addMutableTrackWithMediaType:AVMediaTypeAudio 
preferredTrackID:kCMPersistentTrackID_Invalid];

if not followed with a valid

[compositionAudioTrack insertTimeRange:
     CMTimeRangeMake(kCMTimeZero, [url duration]) 
     ofTrack:audioTrack 
     atTime:insertionPoint error:&error];

So the test on audioTrack != nil is not enough.

I combine two audio tracks with one video with no problems anymore for IOS 9.

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