NextLevelSessionExporter icon indicating copy to clipboard operation
NextLevelSessionExporter copied to clipboard

Error 3 (cancelled) on attempt to export video from iPhone 16 with APAC audio codec

Open Igor-Poltavtsev opened this issue 1 year ago • 2 comments

We have an issue on v.0.4.6 on exporting video created on iPhone 16 with APAC audio codec. Any suggestions?

Igor-Poltavtsev avatar Oct 09 '24 20:10 Igor-Poltavtsev

I concur - have same issue on an iPhone 16 Pro with videos recorded on the iPhone 16 Pro device. The problem seems to be Record Sound = Spacial in Settings.app | Camera. The videos have 2 audio tracks, one of them the problematic APAC track. I have partially solved it for now by modifying NextLevelSessionExporter.setupAudioOutput() by filtering out the APAC track before submitting it to AVAssetReaderAudioMixOutput:

NextLevelSessionExporter.swift:418 - setupAudioOutput()

...
        var audioTracksToUse: [AVAssetTrack] = []
        // Remove APAC tracks
        for audioTrack in audioTracks {
            let mediaSubtypes = audioTrack.formatDescriptions.filter { CMFormatDescriptionGetMediaType($0 as! CMFormatDescription) == kCMMediaType_Audio }.map { CMFormatDescriptionGetMediaSubType($0 as! CMFormatDescription) }
            for mediaSubtype in mediaSubtypes where mediaSubtype != kAudioFormatAPAC {
                audioTracksToUse.append(audioTrack)
            }
        }
        self._audioOutput = AVAssetReaderAudioMixOutput(audioTracks: audioTracksToUse, audioSettings: nil)

...

belgiandubbel avatar Oct 09 '24 20:10 belgiandubbel

Thanks, @belgiandubbel we applied similar solution and seems it works. We modify incoming assets - remove track with apac codec. After NextLevelSessionExporter will be updated we just remove our custom solution.

Igor-Poltavtsev avatar Oct 13 '24 10:10 Igor-Poltavtsev

Please take a moment to review PR https://github.com/NextLevel/NextLevelSessionExporter/pull/51

gardner avatar May 30 '25 11:05 gardner

📎 https://github.com/NextLevel/NextLevelSessionExporter/pull/51

piemonte avatar May 30 '25 19:05 piemonte