Class

AVMetadataItem

A metadata item associated with an audiovisual asset or one of its tracks.

Overview

To effectively use AVMetadataItem, you need to understand how AVFoundation organizes metadata. To simplify finding and filtering metadata items, the framework groups related metadata into key spaces:

  • Format-specific key spaces. The framework defines a number of format-specific key spaces. They roughly correlate to a particular container or file format, such as QuickTime (Quicktime Metadata and User Data) or MP3 (ID3). However, a single asset may contain metadata values across multiple key spaces. To retrieve an asset's complete collection of format-specific metadata, you use its metadata property.

  • Common key space. There are a number of common metadata values, such as a movie’s creation date or description, that can exist across multiple key spaces. To help normalize access to this common metadata, the framework provides a common key space that gives access to a limited set of metadata values common to several key spaces. This makes it easy to retrieve commonly used metadata without concern for the specific format. To retrieve an asset’s collection of common metadata, you use its commonMetadata property.

Metadata items have keys that accord with the specification of the container format from which they’re drawn. Full details of the metadata formats, metadata keys, and metadata key spaces supported by AVFoundation are available in AVMetadataKeySpace and AVMetadataKey.

To load values of a metadata item “lazily,” you use the methods from the AVAsynchronousKeyValueLoading protocol (see Asynchronous Loading). The AVAsset class and other classes in turn provide their metadata lazily so that you can obtain objects from those arrays without incurring overhead for items you don’t ultimately inspect.

To filter arrays of metadata items, you use the methods of this class. For example, you can filter by key and key space, by locale, and by preferred language.

Topics

Getting Keys and Key Spaces

var key: (NSCopying & NSObjectProtocol)?

The key of the metadata item.

var keySpace: AVMetadataKeySpace?

The key space of metadata item’s key.

struct AVMetadataKeySpace

A value that defines a metadata key space.

var commonKey: AVMetadataKey?

The common key of the metadata item.

struct AVMetadataKey

A value that specifies a type of metadata

Accessing Metadata Values

var value: (NSCopying & NSObjectProtocol)?

The value of the metadata item.

var time: CMTime

The timestamp of the metadata item.

var duration: CMTime

The duration of the metadata item.

var locale: Locale?

The locale of the metadata item.

var dataValue: Data?

Provides the raw bytes of the value of the metadata item.

var extraAttributes: [AVMetadataExtraAttributeKey : Any]?

The additional attributes supplied by the metadata item.

var dataType: String?

The data type of the metadata item's value.

var extendedLanguageTag: String?

The IETF BCP 47 (RFC 4646) language identifier of the metadata item.

var startDate: Date?

The start date of the timed metadata; nil if no date is indicated.

class func identifier(forKey: Any, keySpace: AVMetadataKeySpace)

Provides the metadata identifier that’s equivalent to a key and key space.

struct AVMetadataKeySpace

A value that defines a metadata key space.

var identifier: AVMetadataIdentifier?

The identifier of the metadata item.

class func key(forIdentifier: AVMetadataIdentifier)

Provides the metadata key indicated by the identifier.

class func keySpace(forIdentifier: AVMetadataIdentifier)

Gets the metadata keySpace indicated by the identifier.

struct AVMetadataIdentifier

A value that defines the metadata identifiers for different file formats.

Retrieving Formatted Metadata

var stringValue: String?

The value of the metadata item formatted as a string.

var numberValue: NSNumber?

The value of the metadata item formatted as a number.

var dateValue: Date?

The value of the metadata item formatted as a date.

Filtering Arrays of Metadata Items

class func metadataItems(from: [AVMetadataItem], withKey: Any?, keySpace: AVMetadataKeySpace?)

Provides an array of metadata items that match a specified key or key space.

struct AVMetadataKeySpace

A value that defines a metadata key space.

class func metadataItems(from: [AVMetadataItem], with: Locale)

Provides an array of metadata items that match a specified locale.

class func metadataItems(from: [AVMetadataItem], filteredAndSortedAccordingToPreferredLanguages: [String])

Provides the subset of metadata items whose locales match one of the specified language identifiers.

class func metadataItems(from: [AVMetadataItem], filteredBy: AVMetadataItemFilter)

Filters an array of metadata items using the metadata item filter.

struct AVMetadataIdentifier

A value that defines the metadata identifiers for different file formats.

init(propertiesOf: AVMetadataItem, valueLoadingHandler: (AVMetadataItemValueRequest) -> Void)

Creates a metadata item intended for optional display purposes.

See Also

Metadata Manipulation

Finding Metadata Values

Retrieve and filter all of the metadata associated with an asset.

JavaScript Object Notation (JSON) Chapter Format for HTTP Live Streaming

Understand the JSON chapter formatting required for HTTP Live Streaming.

class AVMetadataGroup

A collection of metadata items associated with a timeline segment.

class AVMetadataItemFilter

An object that filters selected information from a metadata item.

class AVMetadataItemValueRequest

An object used to respond to a request to load the value of a metadata item.

class AVMutableMetadataItem

A mutable metadata item associated with an audiovisual asset or with one of its tracks.

class AVDateRangeMetadataGroup

A collection of metadata items that are valid for use within a specific date range.

class AVMutableDateRangeMetadataGroup

A mutable collection of metadata items that are valid for use within a specific range of dates.

class AVTimedMetadataGroup

A collection of metadata items that are valid for use during a specific time range.

class AVMutableTimedMetadataGroup

A mutable collection of metadata items that are valid for use during a specific time range.

struct AVMetadataFormat

A value that defines a metadata format.