Make sure to read my article on AVAssetWriter crashing when using CMAF compliant segments before exploring this sample project.
Minimal sample to demonstrate writing out CMAF compliant segments from a real source fails with an error on Intel macs on Ventura.
The error is in the AVFoundationErrorDomain with code -11800, containing an underlying error in the NSOSStatusErrorDomain with code -16364.
- The
AVAssetWritermust be configured withoutputFileTypeProfileset to.mpeg4CMAFCompliant. - The
AVAssetWriterInputadded to the writer must haveexpectsMediaDataInRealTimeset totrue. - Samples must be appended to the input either:
- At an variable rate, for example because no new sample is generated when there is no change at the souce (like ScreenCaptureKit does).
- Frames are delivered significantly faster than 60 FPS.
- The application must run on an Intel mac, Apple Silicon macs are not affected.
This repository contains a sample app demonstrating the issue:
- Open
realtime-cmaf-crash-sample.xcodeprojin Xcode 14.2 or newer on an Intel mac - Build & run the app
- Hit the "Start" button
After about 5 segments are delivered to the delegate the app will crash.
- On the
AVAssetWriterchangeoutputFileTypeProfiletompeg4AppleHLS.- Note that this will either produce a different format output.
- On the
AVAssetWriterInputsetexpectsMediaDataInRealTimetofalse.- Might have unexpected side effects dropping frames because
isReadyForMoreMediaDatamight become inaccurate.
- Might have unexpected side effects dropping frames because
Nonstrict B.V., Mathijs Kadijk & Tom Lokhorst, released under MIT License.