如何在iOS上使用AVFoundation设置M4A文件的图稿?

时间:2015-05-05 19:56:39

标签: ios image metadata avfoundation m4a

我有一个M4A文件,我想从UIImage设置其作品。这是我到目前为止所得到的:

AVURLAsset* asset = [AVAsset assetWithURL:outputURL];
AVMutableMetadataItem* item = [AVMutableMetadataItem metadataItem];
item.key = AVMetadataCommonKeyArtwork;
item.keySpace = AVMetadataKeySpaceiTunes;

UIImage *image = [UIImage imageWithContentsOfFile:path];
NSData *imageData = UIImagePNGRepresentation(image);
item.value = imageData;
NSArray* metadata = [NSArray arrayWithObject:item];

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetAppleM4A];

exportSession.outputURL = outputURL;
exportSession.outputFileType = AVFileTypeAppleM4A;
exportSession.metadata = metadata;

[exportSession exportAsynchronouslyWithCompletionHandler:^{
    // ...
}];

我尝试了一些不同的事情,包括:

  • AVMetadataKeySpaceCommon
  • JPEG图片
  • 导出到与现有文件不同的网址
  • 元数据项值为具有data键的字典,而不仅仅是数据

我试图根据如何从文件中获取元数据的示例进行推断,因为我无法在任何地方找到有关此内容的任何文档。任何帮助表示赞赏。

0 个答案:

没有答案