I am using AVAssetExportSession for encoding video. For some source files(not all files), there is out of sync between video and audio after exporting by AVAssetExportSession without editing.
This issue causes when I put AVMutableComposition to asset parameter in the initialization of AVAssetExportSession.(There is no out of sync when I put source asset directly to asset parameter.) I just created a new AVMutableComposition. And I inserted video track and audio track of source assets to AVMutableComposition. But, the result of the export session has out of sync.
Here is an image of audio tracks of source assets and exported video.
Source asset and exported video
Audio 1 track is for source and Audio 2 track is for exported video. The audio of the exported video is faster by about 0.05 seconds than the original one.
Through some searches, I doubt this problem is related to Encoder delay(Encoder delay). Because 0.05 seconds with 44100Hz is about 2112 samples. But I am not sure. Can it resolve with AVAssetExportSession? Or Should I use AVAssetReader/AVAssetWriter or others which is more controllable than AVAssetExportSession? Are there any solutions?