2011-02-21 11 views
8

Sto tentando di identificare i diversi elementi dei metadati su un video sull'iPad. Finora sono stato in grado di utilizzare con successo le librerie AVAsset per trovare il file e generare un array di AVMetadataItems usando metadataForFormat:. Nel file sono stati trovati solo i formati di dati di iTunes e Quicktime User. Il problema ora è che ho quell'informazione, non ho modo di identificare cosa è cosa. Intendevo caricare un dizionario con le informazioni, indicizzato dalla chiave dei metadati, ma l'utilizzo della proprietà key di AVMetadataItem sembra non funzionare correttamente come se restituisse un numero (il debugger dice che è un NSCFNumber). Ecco alcuni esempi di codice di quello che sto facendo:Recupero del nome della chiave su AVMetadataItem per un set AVA in iOS

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

Questo produce il seguente output nella console debugger:

metadata: key = -1452383891 
metadata: key = -1452841618 
metadata: key = 1684370275 
metadata: key = 1818518899 
metadata: key = 1937009003 
metadata: key = -1453101708 

Per inciso, cambiando la linea NSLog a leggere:

NSLog(@"metadata: %@", meta); 

ci dà come:

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

Qualsiasi aiuto è molto apprezzato!

risposta

10

Sembra che questi tasti sono codificati i tag ID3:

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

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

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

ecc

+0

GRANDE, grazie per la risposta, ho avuto un'idea di questo ... qualche idea se esiste un metodo per decodificarli? – wideize

+0

Hmm .. questo è testato, ma penso che qualcosa di simile 'chiave NSInteger = [tasto meta];' ' NSString * keystring = [NSString stringWithFormat: "% 4s" @, & key]' dovrebbe funzionare. – tundrabot

+4

Grazie ... Ecco cosa ho finito per fare: NSUInteger akey = NSSwapInt ([(NSNumber *) [meta key] unsignedIntegerValue]); NSString * keyString = [NSString stringWithFormat: @ "%. 4s", &akey]; – wideize

Problemi correlati