Instance Method


Initiates a sample-writing session for the output asset.


func startSession(atSourceTime startTime: CMTime)



The starting asset time for the sample-writing session, in the timeline of the source samples.


Sequences of sample data appended to the asset writer inputs are considered to fall within “sample-writing sessions.” You must call this method to begin one of these sessions.

Each writing session has a start time which, where allowed by the file format being written, defines the mapping from the timeline of source samples onto the file's timeline. In the case of the QuickTime movie file format, the first session begins at movie time 0, so a sample appended with timestamp T will be played at movie time (T-startTime). Samples with timestamps before startTime will still be added to the output media but will be edited out of the movie. If the earliest buffer for an input is later than startTime, an empty edit will be inserted to preserve synchronization between tracks of the output asset.

Special Considerations

It is an error to invoke this method twice in a row without invoking endSession(atSourceTime:): in between.

See Also

Managing Session Time

func endSession(atSourceTime: CMTime)

Concludes a sample-writing session.