Target : ipod library -> aiff / wav / caf (which eat by libsndfile (already ported to ios))
first, i think AVAssetExportSession can solve my problem due to this link:
http://tuchangwei.github.io/blog/2013/06/04/how-to-export-mp3-from-ipod-library/
but it is for converted-to-mp3 only (or converted-to-m4a)
(Trick :
Some points you need notice:
when you init AVAssetExportSession object, the “presetName” argument must be “AVAssetExportPresetPassthrough”.
The “outputFileType” may be “com.apple.quicktime-movie”.
And rename to mp3)
why i know it is for mov or m4a
if u write :
NSLog(@”export.supportedFileTypes : %@”,export.supportedFileTypes);
u will get:
exporter.supportedFileTypes : (
“com.apple.quicktime-movie”,
“com.apple.m4a-audio”,
“public.mpeg-4”,
“com.apple.m4v-video”,
“public.3gpp”,
“org.3gpp.adaptive-multi-rate-audio”,
“com.microsoft.waveform-audio”,
“public.aiff-audio”,
“public.aifc-audio”,
“com.apple.coreaudio-format”
)
but it is only telling u these type exporter can convert
in api:
Discussion
Not all presets are compatible with all assets.
So after i run
NSLog(@”%@”, [AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);
2014-05-27 18:29:35.792 Jtab[1723:60b] (
AVAssetExportPresetAppleM4A,
AVAssetExportPreset960x540,
AVAssetExportPresetLowQuality,
AVAssetExportPresetMediumQuality,
AVAssetExportPreset640x480,
AVAssetExportPresetHighestQuality,
AVAssetExportPreset1280x720
)
only m4a is available (and mp3 using mov one)
whatever your ipod library song is mp3, m4a, wav (i tried)
so it is fail
And note that using AVAssetExportSession, the output extension is concerned, if type != extension will error
So i go to other solution AVAssetWriter:
wav example:
http://objective-audio.jp/2010/09/avassetreaderavassetwriter.html
wav example:
http://iphonedevsdk.com/forum/iphone-sdk-development/62807-export-audio-as-m4a-alac.html
caf example:
http://swordinhand.iteye.com/blog/1942043
同場加映:
Easy AAC compressed audio conversion on iOS
http://atastypixel.com/blog/easy-aac-compressed-audio-conversion-on-ios/
using https://github.com/michaeltyson/TPAACAudioConverter
But i think use AVAssetExportSession to m4a can solve the problem…,so TPAACAudioConverter is useless now