1

如何AVAssetExportSession在保留 id3 标签的同时导出 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];
    }
}];
4

0 回答 0