在AVMetadataItem上检索iOS中AVAsset的密钥名称

wid*_*ize 8 iphone video xcode ipad ios

我试图在iPad上识别视频上的不同元数据项.到目前为止,我能够成功使用AVAsset库来查找文件,并使用生成AVMetadataItems数组metadataForFormat:.仅在文件中找到iTunes和Quicktime用户数据格式.现在的问题是我掌握了这些信息,我无法确定是什么.我打算用元数据键加载带有信息的字典,但是使用keyAVMetadataItem 的属性似乎不能正常工作,好像返回一个数字(调试器说它是一个NSCFNumber).以下是我正在做的一些示例代码:

ALAssetRepresentation *representation = [[valAsset defaultRepresentation] retain];
NSURL *url = [representation url];
AVURLAsset *aAsset = [[AVURLAsset URLAssetWithURL:url options:nil] retain];
metaDataDict = [[NSMutableDictionary dictionary] retain];
NSArray *fmtmetadata = [aAsset metadataForFormat:@"com.apple.itunes"];
for (AVMetadataItem* meta in fmtmetadata)
{
    [metaDataDict setObject:[meta stringValue]
             forKey:[meta key]];
    NSLog(@"metadata: key = %@", [meta key]);
}
Run Code Online (Sandbox Code Playgroud)

这会在调试器控制台中产生以下输出:

metadata: key = -1452383891
metadata: key = -1452841618
metadata: key = 1684370275
metadata: key = 1818518899
metadata: key = 1937009003
metadata: key = -1453101708
Run Code Online (Sandbox Code Playgroud)

顺便提一下,将NSLog行更改为:

NSLog(@"metadata: %@", meta);
Run Code Online (Sandbox Code Playgroud)

给我们输出像:

metadata: keySpace=itsk, key=desc, commonKey=(null), locale=(null), value=This is the Description of the Video, time={INVALID}, duration={INVALID}, extras={
    dataType = 1;
}
Run Code Online (Sandbox Code Playgroud)

任何帮助是极大的赞赏!

小智 10

看起来这些键是编码的ID3标签:

1684370275 = 0x64657363 = {'d','e','s','c'}

1818518899 = 0x6C646573 = {'l','d','e','s'}

1937009003 = 0x7374696B = {'s','t','i','k'}

等等

  • 谢谢......这是我最终做的事情:NSUInteger akey = NSSwapInt([(NSNumber*)[meta key] unsignedIntegerValue]); NSString*keyString = [NSString stringWithFormat:@"%.4s",&akey]; (4认同)