One Logo Pool Ball
AVFoundation · IOS API REFERENCE

AVAssetWritingPlanner

class · iOS 27.0+ · SDK 27.1

class AVAssetWritingPlanner

Members (6)

static · iOS 27.0+

segmentBoundaryRecommendations

TypeScript
static segmentBoundaryRecommendations(videoAssetTrack: AVAssetTrack, minimumSegmentDuration: _CoreMedia_CMTime, minimumSegmentFrameCount: number): Array<AVPlannedVideoSegmentConfiguration>
Swift declaration
class func segmentBoundaryRecommendations(forVideoTrack videoAssetTrack: AVAssetTrack, minimumSegmentDuration: CMTime, minimumSegmentFrameCount: Int) -> [AVPlannedVideoSegmentConfiguration]
get · iOS 27.0+

progress

TypeScript
get progress(): AVAssetWritingPlannerProgress
Swift declaration
var progress: AVAssetWritingPlannerProgress { get }
method · iOS 27.0+

executePlan

TypeScript
executePlan(): Promise<AVComposition>
Swift declaration
func executePlan() async throws -> AVComposition

Starts the incremental segment writing. The planner calls every segment handler sequentially, starting with the first one available, or at the next unfinished segment if resuming a previously canceled session. Upon success (no error thrown), this means that all segments for all tracks have been completed. The returned assemblyComposition can be used to put the incremental tracks back together. One way to accomplish this is by feeding the assemblyComposition through AVAssetExportSession with the pass-through preset. The client is responsible for combining any other tracks (those that were not eligible for incremental writing), as well as establishing any track references between the incrementally written tracks and the other tracks in the final asset. - Returns: The assembly composition containing all completed segments from all tracks. - Throws: An error if the export fails or if a segment handler reports an error.

init · iOS 27.0+

init

TypeScript
static init(directoryForTemporaryFiles: string): AVAssetWritingPlanner
Swift declaration
convenience init(directoryForTemporaryFiles: URL) throws

Creates an instance of AVAssetWritingPlanner given a unique file directory to host all incremental segment files and other intermediate files. The `directoryForTemporaryFiles` must differ between export operations, but remain identical when resuming the same export operation. The client is responsible for ensuring that this URL can be re-synthesized exactly across multiple launches of the app and device reboots (if desired). For example, if there are multiple source assets that need to be exported concurrently, these should result in unique URLs so that the planner can correctly identify each one. Another example is if the same source asset is being output with different compression configurations, they also should be uniquely identifiable so that they do not alias to the same output file. A resuming planner instance can only find the files from a previous planner instance if presented with the identical URL. All intermediate segment files and metadata files are stored in the specified `directoryForTemporaryFiles`. Source assets, compression configs, and video composition settings should all be taken into account when generating the unique URL. - Parameter directoryForTemporaryFiles: The file directory to host all incremental segment files and other intermediate files for the current AVAssetWritingPlanner operation. - Throws: An error if `directoryForTemporaryFiles` does not exist, or it is not writable, or it contains a corrupted AVAssetWritingPlanner incremental state file.

static · iOS 27.0+

segmentBoundaryGuidelinesForVideo

TypeScript
static segmentBoundaryGuidelinesForVideo(codecType: AVVideoCodecType, encoderSpecification: Record<string, SDKHandle>): AVAssetWritingPlanner_SegmentBoundaryGuidelines
Swift declaration
static func segmentBoundaryGuidelinesForVideo(codecType: AVVideoCodecType, encoderSpecification: [String : any Sendable]) -> AVAssetWritingPlanner.SegmentBoundaryGuidelines

Returns segment boundary guidelines that help clients determine how to segment compression video tracks with best results. The encoderSpecification parameter here is the same encoder specification the client uses to compress the video track. - Parameters: - codecType: The output video codec type for the video track. - encoderSpecification: A dictionary of kVTVideoEncoderSpecification_* keys describing the video encoder. This is the same specification the client uses to compress the video track. - Returns: An AVAssetWritingPlanner.SegmentBoundaryGuidelines with the minimum frame count and duration for the given codec and encoder.

method · iOS 27.0+

plan

TypeScript
plan(trackPlan: AVAssetTrackPlan, segmentHandler: ((arg0: AVPlannedSegmentWritingRequest) => Promise<AVAssetWritingPlanner_SegmentResult>)): void
Swift declaration
func plan(_ trackPlan: AVAssetTrackPlan, segmentHandler: @escaping @Sendable (AVPlannedSegmentWritingRequest) async throws -> AVAssetWritingPlanner.SegmentResult)

Adds a track plan with manual segment completion control. This variant provides fine-grained control over segment completion, allowing you to return a ``SegmentResult`` that explicitly controls how the segment completes. - Parameters: - trackPlan: The track plan contains information about the track and boundaries of all the segments. - segmentHandler: Handler that returns a ``SegmentResult`` for manual control. ## Topics ### See Also - ``planTrack(_:segmentHandler:)`` - ``SegmentResult``

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

AVAssetWritingPlanner.init()

inherited init: cannot prove legal (class declares 1 custom initializer)

All AVFoundation types →