简体   繁体   English

"如何使用 AVAssetWriter 导出 mp3 文件"

[英]How to export mp3 file with AVAssetWriter

I'm trying to export my asset as an .mp3 file using AVAssetWriter .我正在尝试使用AVAssetWriter将我的资产导出为.mp3文件。

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. [AVAssetWriter initWithURL:fileType:error:]无效的文件类型 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可用的文件类型有: 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.我在 macOS 10.15 上运行此代码。 I find it hard to believe that there's no support for exporting an mp3 file.我很难相信不支持导出 mp3 文件。 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我很难相信不支持导出 mp3 文件

<\/blockquote>

Overcome your difficulty and believe it.克服你的困难并相信它。 Due to a complex of copyright issues, Apple has no license to provide any native capacity to create MP3 files.由于版权问题的复杂性,Apple 没有提供任何本地能力来创建 MP3 文件的许可。 You might find some third party library that can do it, but you won't do it with AVAssetWriter.你可能会发现一些第三方库可以做到这一点,但你不会用 AVAssetWriter 做到这一点。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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