在AVMetadataItem上检索iOS中AVAsset的密钥名称 [英] Retrieving the key name on AVMetadataItem for an AVAsset in iOS
问题描述
我正在尝试在iPad上识别视频中的不同元数据项。到目前为止,我能够成功使用AVAsset库来查找文件,并使用 metadataForFormat:
生成一个AVMetadataItems数组。仅在文件中找到iTunes和Quicktime用户数据格式。现在的问题是我有这些信息,我无法确定是什么。我打算用元数据键加载带有信息的字典,但是使用AVMetadataItem的 key
属性似乎无法正常工作,就像返回一个数字一样(调试器说它的一个NSCFNumber)。以下是我正在做的一些示例代码:
I am trying to identify the different metadata items on a video on the iPad. So far I was able to successfully use the AVAsset libraries to find the file, and generate an array of AVMetadataItems using metadataForFormat:
. Only iTunes and Quicktime User data formats were found in the file. The issue is now that I have that information, I have no way of identifying what is what. I intended to load a dictionary with the information, indexed by the metadata key, but using the key
property of AVMetadataItem appears not to work correctly as if returns a number (debugger says its an NSCFNumber). Here is some sample code of what I am doing:
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]);
}
这会在调试器控制台中产生以下输出:
This yields the following output in the debugger console:
metadata: key = -1452383891
metadata: key = -1452841618
metadata: key = 1684370275
metadata: key = 1818518899
metadata: key = 1937009003
metadata: key = -1453101708
顺便提一下,将NSLog行更改为:
Incidentally, changing the NSLog line to read:
NSLog(@"metadata: %@", meta);
为我们提供如下输出:
metadata: keySpace=itsk, key=desc, commonKey=(null), locale=(null), value=This is the Description of the Video, time={INVALID}, duration={INVALID}, extras={
dataType = 1;
}
非常感谢任何帮助!
推荐答案
看起来这些键是编码的ID3标签:
Looks like these keys are encoded ID3 tags:
1684370275 = 0x64657363 = {'d','e ','s','c'}
1684370275 = 0x64657363 = {'d', 'e', 's', 'c'}
1818518899 = 0x6C646573 = {'l','d','e','s'}
1818518899 = 0x6C646573 = {'l', 'd', 'e', 's'}
1937009003 = 0x7374696B = {'s','t','i','k'}
1937009003 = 0x7374696B = {'s', 't', 'i', 'k'}
等
这篇关于在AVMetadataItem上检索iOS中AVAsset的密钥名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!