如何从 iOS 设备的 iPod 库导出 mp3 文件?
在我的 iOS 应用程序中,我尝试将 mp3 文件从 iPod 库导出到设备上应用程序的文档目录。目前我正在尝试使用 AVAssetExportSession 但它不适用于 mp3 文件。它适用于 m4a 文件。
是否可以使用 AVAssetExportSession 导出 mp3 文件?
适合 AVAssetExportSession 的 outputFileType 是什么? (AVFileTypeAppleM4A 适用于 m4a 文件)
谢谢!
In my iOS application I'm trying to export an mp3 file from the iPod library to the app's documents directory on the device. Currently I'm trying to use AVAssetExportSession but it's not working for mp3 files. It works well for m4a files.
Is exporting an mp3 file possible using AVAssetExportSession?
What is the appropriate outputFileType for AVAssetExportSession? (AVFileTypeAppleM4A works for m4a files)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我面临着同样的问题。不幸的是,没有一个 iOS 框架(AVFoundation、CoreMedia 等)支持 MP3 编码。
类似问题的答案建议使用Lame 编码器 和 另一个问题提到某些用户能够成功编译对于 iOS(“我刚刚尝试为 LAME 构建静态库并确认它‘有效’......”)。
另一种选择是使用 FFMpeg。似乎有些用户已经成功地为 iOS 4.3 编译了它(请参阅此参考)。
请考虑到您可能需要支付 MP3 编码的版税。此外,FFMpeg/Lame 的许可证可能会阻止您在闭源应用程序中使用其代码。
祝你好运!
I am facing the same problem. Unfortunately, non of the iOS frameworks (AVFoundation, CoreMedia, etc) support encoding to MP3.
An answer to a similar question suggest using the Lame Encoder, and another question mentions that some user was able to compile is successfully for iOS ("I have just attempted to build the static library for LAME and confirmed that it 'works'...").
Another alternative would be to go with FFMpeg. It seems like some users have successfully compiled it for iOS 4.3 (see this reference).
Take into account that you may have to pay royalties for encoding MP3. Also, the licenses for FFMpeg/Lame may prevent you from using their code in a closed-source application.
Good luck!
看来
AVAssetExportSession
仅支持使用 com.apple.quicktime-movie (.mov) 和 com.apple.coreaudio-format 进行 mp3 转码的文件类型(.caf) 使用AVAssetExportPresetPassthrough
预设。您还必须确保在写入输出文件时使用这些文件扩展名之一,否则它将无法保存。mp3 输入文件支持的输出文件类型和扩展名以粗体显示(在 OS X 10.11.6 上测试):
It appears
AVAssetExportSession
only supports filetypes for mp3 transcoding with com.apple.quicktime-movie (.mov) and com.apple.coreaudio-format (.caf) using theAVAssetExportPresetPassthrough
preset. You must also be sure to use one of these file extensions when writing your output file otherwise it won't save.Supported output filetype and extensions for an mp3 input file are in bold (tested on OS X 10.11.6):
这里的代码将帮助您从音乐库导出 mp4
here code that will help you to export an mp4 from music library