我尝试了许多方法,但无法正常工作。这些文件在一个文件中互相播放,但不能同时播放。
let composition = AVMutableComposition(urlAssetInitializationOptions: [AVURLAssetPreferPreciseDurationAndTimingKey:true])
let compositionAudioTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: kCMPersistentTrackID_Invalid)
let lineOne = AVAsset(url: urls[0])
let lineTwo = AVAsset(url: urls[1])
do {
try compositionAudioTrack?.insertTimeRange(CMTimeRange(start: CMTime.zero, duration: lineOne.duration), of: lineOne.tracks.first!, at: CMTime.zero)
try compositionAudioTrack?.insertTimeRange(CMTimeRange(start: CMTime.zero, duration: lineTwo.duration), of: lineTwo.tracks.first!, at: CMTime.zero)
} catch {
print("err")
}