首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >改变AVMetadataItem

改变AVMetadataItem
EN

Stack Overflow用户
提问于 2013-01-18 04:12:17
回答 1查看 1.8K关注 0票数 6

我有一些文件,-m4a -mp4 -mp3等。我想更改这些细节。

  • AVMetadataItem
  • AVMetadataCommonKeyArtwork
  • AVMetadataCommonKeyArtist

我可以使用AVAssetExportSession,但我需要更改目录。我能直接在文件上写字吗?

我找到了这个程序,但不起作用

代码语言:javascript
复制
NSError *error;
AVAssetWriter *assetWrtr = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:self.path] fileType:AVFileTypeAppleM4A error:&error];
NSLog(@"%@",error);

NSArray *existingMetadataArray = assetWrtr.metadata;
NSMutableArray *newMetadataArray = nil;
if (existingMetadataArray)
{
    newMetadataArray = [existingMetadataArray mutableCopy]; // To prevent overriding of existing metadata
}
else
{
    newMetadataArray = [[NSMutableArray alloc] init];
}


 AVMutableMetadataItem *item = [[AVMutableMetadataItem alloc] init];
item.keySpace = AVMetadataKeySpaceCommon;
item.key = AVMetadataCommonKeyArtwork;
item.value = UIImagePNGRepresentation([[UIImage alloc] initWithContentsOfFile:[[NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@".image"]]);

[newMetadataArray addObject:item];
assetWrtr.metadata = newMetadataArray;



[assetWrtr startWriting];
[assetWrtr startSessionAtSourceTime:kCMTimeZero];
EN

回答 1

Stack Overflow用户

发布于 2014-09-04 11:31:24

UIImagePNGRepresentation更改为UIImageJPEGRepresentation,您需要jpeg数据,而不是png。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14392252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档