2013-01-18 7 views
5

나는 이러한 세부변경 AVMetadataItem

  • AVMetadataItem
  • AVMetadataCommonKeyArtwork
  • AVMetadataCommonKeyArtist
내가 함께 할 수있는

을 변경하려면, -m4a -mp4 -MP3 등 일부 파일이 AVAssetExportSession,하지만 디렉토리를 변경해야합니다. 파일에 직접 쓸 수있는 방법이 있습니까?

나는이 프로그램을 찾았지만 작동하지 않습니다 :(

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]; 

답변

3

변화를 당신이 JPEG 데이터는 PNG로 할 필요가 없습니다 UIImagePNGRepresentation UIImageJPEGRepresentation에.