swift video compression removes sound when video length gets to a certain amount

Viewed 33

im using

 func compressVideo(inputURL: URL,
                   outputURL: URL,
                   handler:@escaping (_ exportSession: AVAssetExportSession?) -> Void) {
    let urlAsset = AVURLAsset(url: inputURL, options: nil)
    guard let exportSession = AVAssetExportSession(asset: urlAsset,
                                                   presetName: AVAssetExportPresetLowQuality) else {
        handler(nil)
        
        return
    }
    
    exportSession.outputURL = outputURL
    exportSession.outputFileType = .mp4
    exportSession.exportAsynchronously {
        handler(exportSession)
    }
}

this code to compress video but when the video goes over a certain length sound from the video is removed/deleted what can I do to resolve this problem

1 Answers

I found the solution on my own. I've changed the video format to .mov and it worked.

Related