Oranutachi
Oranutachi

Reputation: 1279

Export files with AVAssetExportSession without changing their format (Swift 5)

In my app I download music files from the Music Library to the Documents folder. I've tried many options, including looking on this site, but they all suggest using AVAssetExportSession and .outputFileType = AVFileType.m4a. But I don't want to convert files to this format, I would like the files to be exported in the same format in which they are stored in the Music Library. How can I do it?

My code:

...
    let exportSession = AVAssetExportSession(asset: AVAsset(url: url), presetName: AVAssetExportPresetAppleM4A)
    exportSession?.shouldOptimizeForNetworkUse = true
    exportSession?.outputFileType = AVFileType.m4a
...

Upvotes: 4

Views: 368

Answers (0)

Related Questions