Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use AVFoundation to modify audio metadata

I'm working on an app which needs to modify metadata of audio files. I have played with Apple's official demo AVReaderWriterOSX. I have tried to set the metadata of AVAssetWriterInput and AVAssetWriter, but I still can't make it work to write metadata to the output file. Does anyone have any examples for this?

Thank you in advance.

like image 798
nonamelive Avatar asked Dec 14 '11 16:12

nonamelive


1 Answers

I think I have found the solution. The simplest solution is to use AVAssetExportSession.

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
    initWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
exportSession.outputURL = ...;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
exportSession.timeRange = CMTimeRangeMake(startTime, duration);
exportSession.metadata = ...;
[exportSession exportAsynchronouslyWithCompletionHandler:handlerBlock];
like image 148
nonamelive Avatar answered Sep 26 '22 02:09

nonamelive