简体   繁体   中英

How to export mp3 file with AVAssetWriter

I'm trying to export my asset as an .mp3 file using AVAssetWriter .

Here's how I create an instance of it:

writer = try! AVAssetWriter(url: outputURL,
                            fileType: AVFileType.mp3)

Unfortunately, it throws the error:

[AVAssetWriter initWithURL:fileType:error:] Invalid file type UTI.

Available file types are: com.scenarist.closed-caption, org.w3.webvtt, public.aiff-audio, com.apple.m4v-video, org.3gpp.adaptive-multi-rate-audio, com.apple.m4a-audio, com.microsoft.waveform-audio, com.apple.coreaudio-format, public.mpeg-4, com.apple.itunes-timed-text, com.apple.quicktime-movie, public.aifc-audio

I'm running this code on macOS 10.15. I find it hard to believe that there's no support for exporting an mp3 file. Can anyone guide me on how to make it work?

I find it hard to believe that there's no support for exporting an mp3 file

<\/blockquote>

Due to a complex of copyright issues, Apple has no license to provide any native capacity to create MP3 files. You might find some third party library that can do it, but you won't do it with AVAssetWriter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM