<!--
{
  "availability" : [
    "iOS: 4.1.0 -",
    "iPadOS: 4.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetReader",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetReader"
  },
  "title" : "AVAssetReader"
}
-->

# AVAssetReader

An object that reads media data from an asset.

```
class AVAssetReader
```

## Overview

Use an asset reader to read media data from instances of [`AVAsset`](/documentation/AVFoundation/AVAsset). The assets you read may represent file-based media like QuickTime movies or MPEG-4 files, or media that you compose from multiple sources using [`AVComposition`](/documentation/AVFoundation/AVComposition).

## Topics

### Creating an asset reader

[`init(asset: AVAsset) throws`](/documentation/AVFoundation/AVAssetReader/init(asset:))

Creates an object to read media data from an asset.

[`+ (instancetype) assetReaderWithAsset:(AVAsset *) asset error:(NSError **) outError;`](/documentation/AVFoundation/AVAssetReader/assetReaderWithAsset:error:)

Returns a new object to read media data from an asset.

### Managing outputs

[`func canAdd(AVAssetReaderOutput) -> Bool`](/documentation/AVFoundation/AVAssetReader/canAdd(_:))

Determines whether you can add the output to the asset reader.

[`func add(AVAssetReaderOutput)`](/documentation/AVFoundation/AVAssetReader/add(_:))

Adds an output to the reader.

[`var outputs: [AVAssetReaderOutput]`](/documentation/AVFoundation/AVAssetReader/outputs)

The outputs from which you read media data.

### Accessing output providers

[`func outputProvider(for: AVAssetReaderOutput) -> sending AVAssetReaderOutput.Provider<CMReadySampleBuffer<CMSampleBuffer.DynamicContent>>`](/documentation/AVFoundation/AVAssetReader/outputProvider(for:))

Attaches the output to the reader and returns an output provider for reading sample buffers.

[`func outputProviderWithRandomAccess(for: AVAssetReaderOutput) -> sending (AVAssetReaderOutput.Provider<CMReadySampleBuffer<CMSampleBuffer.DynamicContent>>, AVAssetReaderOutput.RandomAccessController)`](/documentation/AVFoundation/AVAssetReader/outputProviderWithRandomAccess(for:))

Attaches the output to the reader and returns a tuple with an output provider for reading sample buffers, and an associated random access controller.

[`func outputCaptionProvider(for: AVAssetReaderTrackOutput, validationDelegate: (any AVAssetReaderCaptionValidationHandling)?) -> sending AVAssetReaderOutput.Provider<AVCaptionGroup>`](/documentation/AVFoundation/AVAssetReader/outputCaptionProvider(for:validationDelegate:))

Attaches the output to the reader and returns an output provider for reading caption groups.

[`func outputCaptionProviderWithRandomAccess(for: AVAssetReaderTrackOutput, validationDelegate: (any AVAssetReaderCaptionValidationHandling)?) -> sending (AVAssetReaderOutput.Provider<AVCaptionGroup>, AVAssetReaderOutput.RandomAccessController)`](/documentation/AVFoundation/AVAssetReader/outputCaptionProviderWithRandomAccess(for:validationDelegate:))

Attaches the output to the reader and returns a tuple with an output provider for reading caption groups, and an associated random access controller.

[`func outputMetadataProvider(for: AVAssetReaderTrackOutput) -> sending AVAssetReaderOutput.Provider<AVTimedMetadataGroup>`](/documentation/AVFoundation/AVAssetReader/outputMetadataProvider(for:))

Attaches the output to the reader and returns an output provider for reading timed metadata groups.

[`func outputMetadataProviderWithRandomAccess(for: AVAssetReaderTrackOutput) -> sending (AVAssetReaderOutput.Provider<AVTimedMetadataGroup>, AVAssetReaderOutput.RandomAccessController)`](/documentation/AVFoundation/AVAssetReader/outputMetadataProviderWithRandomAccess(for:))

Attaches the output to the reader and returns a tuple with an output provider for timed metadata groups buffers, and an associated random access controller.

### Configuring reading

[`var timeRange: CMTimeRange`](/documentation/AVFoundation/AVAssetReader/timeRange)

The time range within the asset to read.

[`var status: AVAssetReader.Status`](/documentation/AVFoundation/AVAssetReader/status-swift.property)

The status of reading sample buffers from the asset.

[`enum Status`](/documentation/AVFoundation/AVAssetReader/Status-swift.enum)

Values that represent the possible states of an asset reader.

[`var error: (any Error)?`](/documentation/AVFoundation/AVAssetReader/error)

An error that describes the reason for a failure.

### Controlling reading

[`func start() throws`](/documentation/AVFoundation/AVAssetReader/start())

Prepares the reader to read media data from the asset.

[`func startReading() -> Bool`](/documentation/AVFoundation/AVAssetReader/startReading())

Prepares the asset reader to start reading sample buffers from the asset.

[`func cancelReading()`](/documentation/AVFoundation/AVAssetReader/cancelReading())

Cancels any background work and stops the reader’s outputs from reading more samples.

### Inspecting the asset

[`var asset: AVAsset`](/documentation/AVFoundation/AVAssetReader/asset)

The asset from which to read media data.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)