---
title: AVAssetWritingPlanner
framework: avfoundation
role: symbol
role_heading: Class
platforms: [iOS 27.0+, iPadOS 27.0+, Mac Catalyst 27.0+, macOS 27.0+, tvOS 27.0+, visionOS 27.0+]
path: avfoundation/avassetwritingplanner
---

# AVAssetWritingPlanner

AVAssetWritingPlanner orchestrates incremental writing of media files.

## Declaration

```swift
class AVAssetWritingPlanner
```

## Overview

Overview AVAssetWritingPlanner orchestrates an incremental and resumable asset file writing session. It keeps track of the progress of the incremental segments, and can resume the writing from the last checkpoint. This is NOT intended for any real time applications. Also, not all tracks can be written incrementally. The workflow is as follows: The client creates the planner with a unique directoryForTemporaryFiles. The client tells the planner which tracks are to be written incrementally by calling the “planTrack:withSegmentsGeneratedBy:” method, providing a callback block that writes one segment per block invocation. The client kicks off the incremental writing session by calling the “executePlanWithCompletionHandler” method. The planner will call the writingSegmentCallbackBlock to ask the client to write one incremental segment of one track at a time. The client code should write one incremental segment according to the “AVPlannedSegmentWritingRequest” object passed in to the callback block. Clients must call “finish” or “finishWithError” or “finishWithClientState” or “cancel” methods on the request object when it finishes the segment successfully, or encountered an error, or wants to cancel the writing of the segment. At the end of the writing, after all incremental segments are finished, the planner calls the completionHandler. The client can use the “assemblyComposition” object passed in to the completionHandler to assemble the incremental segments into full tracks and export it to a final output file. The completionHandler will also be called when there is any irrecoverable error. The client is responsible for cleaning all files in the directoryForTemporaryFiles after the incremental session is done and the final output file is written. AVAssetWritingPlanner is able to recognize when a plan-in-progress matching the plan was already saved at directoryForTemporaryFiles, presumably by a previous invocation of the client, and possibly aborted due to that client being terminated abruptly, and will assist by resuming the plan at the first step that wasn’t previously completed.

## Topics

### Creating a planner

- [init(directoryForTemporaryFiles:)](avfoundation/avassetwritingplanner/init(directoryfortemporaryfiles:).md)

### Planning tracks

- [plan(_:segmentHandler:)](avfoundation/avassetwritingplanner/plan(_:segmenthandler:).md)

### Executing the plan

- [executePlan()](avfoundation/avassetwritingplanner/executeplan().md)

### Getting segment boundary guidance

- [segmentBoundaryGuidelinesForVideo(codecType:encoderSpecification:)](avfoundation/avassetwritingplanner/segmentboundaryguidelinesforvideo(codectype:encoderspecification:).md)
- [segmentBoundaryRecommendations(forVideoTrack:minimumSegmentDuration:minimumSegmentFrameCount:)](avfoundation/avassetwritingplanner/segmentboundaryrecommendations(forvideotrack:minimumsegmentduration:minimumsegmentframecount:).md)

### Getting progress

- [progress](avfoundation/avassetwritingplanner/progress.md)

### Configuring segment boundaries

- [AVAssetWritingPlanner.SegmentBoundaryGuidelines](avfoundation/avassetwritingplanner/segmentboundaryguidelines.md)

### Handling segment results

- [AVAssetWritingPlanner.SegmentResult](avfoundation/avassetwritingplanner/segmentresult.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Planned export

- [AVAssetWritingPlannerProgress](avfoundation/avassetwritingplannerprogress.md)
- [AVAssetTrackPlan](avfoundation/avassettrackplan.md)
- [AVAssetVideoTrackPlan](avfoundation/avassetvideotrackplan.md)
- [AVPlannedSegmentConfiguration](avfoundation/avplannedsegmentconfiguration.md)
- [AVPlannedVideoSegmentConfiguration](avfoundation/avplannedvideosegmentconfiguration.md)
- [AVPlannedSegmentWritingRequest](avfoundation/avplannedsegmentwritingrequest.md)
- [AVPlannedVideoSegmentWritingRequest](avfoundation/avplannedvideosegmentwritingrequest.md)
