AVAssetExportSession在保留元数据的同时导出mp3

时间:2014-06-08 21:28:43

标签: macos mp3 avfoundation id3 avmetadataitem

如何在保留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];
    }
}];

0 个答案:

没有答案