Iphone 更改AVMetadataItem
我有一些文件,-m4a-mp4-mp3等。 我想改变这些细节Iphone 更改AVMetadataItem,iphone,ios,objective-c,avassetwriter,avmetadataitem,Iphone,Ios,Objective C,Avassetwriter,Avmetadataitem,我有一些文件,-m4a-mp4-mp3等。 我想改变这些细节 AVMetadataItem AVMetadataCommonKeyArtwork avMetadataCommonKeyArtister 我可以使用AVAssetExportSession,但我需要更改目录。有没有办法我可以直接写在文件上 我找到了此程序,但不起作用:( 将UIImagePNGRepresentation更改为uiimagejpegresentation您需要的是jpeg数据,而不是png NSError *er
AVMetadataItem
AVMetadataCommonKeyArtwork
avMetadataCommonKeyArtister
AVAssetExportSession
,但我需要更改目录。有没有办法我可以直接写在文件上
我找到了此程序,但不起作用:(
将UIImagePNGRepresentation更改为uiimagejpegresentation您需要的是jpeg数据,而不是png
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];