I'm trying to only modify the video audio via AVAssetExportSession AudioMix property.
I'm not trimming or doing any other thing except for sound modification. Therefore, I tried using AVAssetExportPresetPassthrough and apply the relevant AudioMix, the AVAssetExportSession works, but the sound remains the same. If I'm changing the preset to AVAssetExportPresetHighestQuality it's much slower but then the audio change works.
Code:
let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetPassthrough)
exportSession.audioMix = audioMix // ignored
let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality)
exportSession.audioMix = audioMix // works
Any idea why? Thanks in advance!
By modifying the
audioMix, you are not passing through. And there's no single-pass way to say "pass through the video track and decode/applyaudioMixthen re-encode in asAVAssetExportPresetHighestQuality", so you could try a two step method:Export the audio track by itself [create an
AVMutableCompositioncontaining only the that track], usingAVAssetExportPresetHighestQuality:Then create a new
AVMutableCompositioncontaining the original video track and your newly created mixed audio track & pass the composition through anAVAssetExportPresetPassthroughAVAssetExportSession.