Post

Replies

Boosts

Views

Activity

Reply to Out of sync between video and audio of video exported by AVAssetExportSession
Yes, but it has still a sync problem. Also, AVAsset.duration and AVAssetTrack.timeRange.duration is actually the same in the log. FYI, here is the stackoverflow link - https://stackoverflow.com/questions/64349186/out-of-sync-between-video-and-audio-of-video-exported-by-avassetexportsession of my question. It has an image about audio tracks between source and exported video.
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’20
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 { }
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’20