Post

Replies

Boosts

Views

Activity

Reply to Out of sync between video and audio of video exported by AVAssetExportSession
Thank you for the reply. Here is my code I use to construct AVMutableComposition. let composition = AVMutableComposition() let videoTrack = composition.addMutableTrack(   withMediaType: AVMediaType.video,   preferredTrackID: kCMPersistentTrackID_Invalid ) let audioTrack = composition.addMutableTrack(   withMediaType: AVMediaType.audio,   preferredTrackID: kCMPersistentTrackID_Invalid ) let assetVideoTrack = asset.tracks(withMediaType: AVMediaType.video).first let assetAudioTrack = asset.tracks(withMediaType: AVMediaType.audio).first let assetDuration = assetVideoTrack?.timeRange.duration   ?? assetAudioTrack?.timeRange.duration   ?? CMTime.zero let timeRange = CMTimeRangeMake(start: CMTime.zero, duration: assetDuration) let atTime = CMTime.zero do {   if let assetVideoTrack = assetVideoTrack {   	try videoTrack?.insertTimeRange(    	 timeRange,    	 of: assetVideoTrack,    	 at: atTime   	)   }   if let assetAudioTrack = assetAudioTrack {   	try audioTrack?.insertTimeRange(    	 timeRange,    	 of: assetAudioTrack,    	 at: atTime   	)   } } catch { }
Oct ’20