AVAssetExportSession export mp3 while keeping metadata

1.4k views Asked by At

How do I export a mp3 using AVAssetExportSession while keeping the id3 tags? Is it possible to edit the id3 tags before exporting them?

This code does write the AVAsset (myMp3Asset) to file but the there are no id3 tag in the resulting mp3.

// 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

There are 0 answers