Class

AVAssetWriter

An object used to write media data to a new file of a specified audiovisual container type.

Declaration

@interface AVAssetWriter : NSObject

Overview

You can get the media data for one or more assets from instances of AVAssetReader or even from outside the AVFoundation API set. Send Media data to AVAssetWriter for writing in the form of CMSampleBuffer. Sequences of sample data appended to the asset writer inputs fall within “sample-writing sessions.” You must call startSessionAtSourceTime: to begin one of these sessions.

Using AVAssetWriter, you can optionally re-encode media samples while writing. You can also optionally write metadata collections to the output file. AVAssetWriter automatically supports interleaving of media data for multiple concurrent tracks.

You can only use a given instance of AVAssetWriter once to write to a single file. You must use a new instance of AVAssetWriter every time you write to a file.

Topics

Creating an Asset Writer

+ assetWriterWithURL:fileType:error:

Returns an asset writer for writing to the file identified by a given URL in a format specified by a given UTI.

- initWithURL:fileType:error:

Creates an asset writer for writing to the file identified by a given URL in a format specified by a given UTI.

availableMediaTypes

The media types you can add inputs to.

Writing Data

- startWriting

Tells the writer to start writing its output.

- finishWriting

Completes the writing of the output file.

Deprecated
- finishWritingWithCompletionHandler:

Marks all unfinished inputs as finished and completes the writing of the output file.

- cancelWriting

Tells the writer to cancel writing.

outputURL

The URL you direct output to.

outputFileType

The file format of the writer’s output.

error

The description of the error that caused the failure.

status

The status of writing samples to the receiver's output file.

AVAssetWriterStatus

The statuses indicating whether a writer can successfully write samples to its output file.

directoryForTemporaryFiles

A suitable directory for containing temporary files generated during the export process.

Managing Inputs

inputs

The asset writer inputs associated with the asset writer.

- addInput:

Adds an input to the receiver.

- canAddInput:

Returns a Boolean value that indicates whether the receiver can add a given input.

Managing Session Time

- startSessionAtSourceTime:

Initiates a sample-writing session for the output asset.

- endSessionAtSourceTime:

Concludes a sample-writing session.

Configuring Output

- canApplyOutputSettings:forMediaType:

Returns a Boolean value that indicates whether the specified output settings support a specified media type.

metadata

The collection of metadata written to the receiver's output file.

movieFragmentInterval

The frequency at which to write movie fragments

overallDurationHint

A hint of the final duration of the file written for file types that support movie fragments.

movieTimeScale

The asset-level time scale to use.

shouldOptimizeForNetworkUse

A Boolean value that indicates whether to write the output file to make it more suitable for playback over a network.

Managing Asset Writer Input Groups

- addInputGroup:

Adds an asset writer input group instance to the asset writer.

- canAddInputGroup:

Returns whether the receiver can add an input group.

inputGroups

An array containing the asset writer input groups added to the asset writer.

Relationships

Inherits From

See Also

File Export

Exporting Video to Alternative Formats

Convert an existing movie file to a different format.

AVAssetExportSession

An object that transcodes the contents of an asset source object to create an output of the form described by a specified export preset.

AVAssetWriterInput

A writer used to append media samples to a single track of an asset writer's output file.

AVVideoTransferFunction_ITU_R_2100_HLG

The transfer function for the ITU_R BT.2100 color space.

AVOutputSettingsAssistant

An object that specifies a set of parameters for configuring objects that use output settings dictionaries.

AVAssetWriterInputGroup

A group of tracks in a mutually exclusive relationship.

AVAssetWriterInputMetadataAdaptor

An object that defines an interface for writing metadata packaged as timed metadata groups into a single asset writer input.

AVAssetWriterInputPassDescription

An object that defines an interface for querying about the requirements of the current pass.

AVAssetWriterInputPixelBufferAdaptor

A buffer used to append video samples packaged as pixel buffers to a single asset writer input.