append(_:decodeTime:presentationTime:)
Appends sample data to a media file and adds sample references for the added data to a track’s media sample tables.
Declaration
func append(_ sampleBuffer: CMSampleBuffer, decodeTime outDecodeTime: UnsafeMutablePointer<CMTime>?, presentationTime outPresentationTime: UnsafeMutablePointer<CMTime>?) throwsParameters
- sampleBuffer:
The sample buffer to be appended.
- outDecodeTime:
A pointer to a Cmtime structure to receive the decode time in the media of the first sample appended from the sample buffer. Pass
NULLif the information is not needed. - outPresentationTime:
A pointer to a Cmtime structure to receive the presentation time in the media of the first sample appended from the sample buffer. Pass
NULLif the information is not needed.
Discussion
If the sample buffer carries sample data, the sample data is written to the container specified by the track property mediaDataStorage if non-nil, or by the movie property defaultMediaDataStorage if non-nil, and sample references are appended to the track’s media. If both media data storage properties are nil, the method will fail and return NO.
If the sample buffer carries sample references only, sample data will not be written and sample references to the samples in their original container are appended to the track’s media as necessary.
To make the new samples appear in the track’s timeline, invoke insertMediaTimeRange(_:into:). Retrieve the mediaPresentationTimeRange property before and after appending a sequence of samples, using CMTimeRangeGetEnd(_:) on each to calculate the media time range for insertMediaTimeRange(_:into:).
It’s safe for multiple threads to call this method on different tracks at the same time.