如何在保留id3标签的同时使用AVAssetExportSession
导出mp3?是否可以在导出之前编辑id3标签?
此代码会将AVAsset
(myMp3Asset)写入文件,但生成的mp3中没有id3标记。
// myMp3Asset is an AVAsset
AVAssetExportSession *exportS = [[AVAssetExportSession alloc]
initWithAsset:myMp3Asset presetName:AVAssetExportPresetPassthrough];
exportS.outputFileType = @"com.apple.quicktime-movie";
NSString *path = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/%@", @"song"];
exportS.outputURL = [NSURL fileURLWithPath:path];;
[exportS exportAsynchronouslyWithCompletionHandler:^{
if (exportS.status == AVAssetExportSessionStatusCompleted)
{
//then rename mov format to the original format.
NSFileManager *manage = [NSFileManager defaultManager];
NSString *mp3Path = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/%@.%@", @"song", @".mp3"];
NSError *error = nil;
[manage moveItemAtPath:path toPath:mp3Path error:&error];
}
}];