Search code examples
iosobjective-cavfoundationavassetwriter

AVAssetWriter - Could not be decoded on this device


Error Domain=AVFoundationErrorDomain Code=-11855 "Cannot Decode" UserInfo={NSUnderlyingError=0x157372050 {Error Domain=NSOSStatusErrorDomain Code=560226676 "(null)"}, NSLocalizedFailureReason=The media data could not be decoded on this device., NSLocalizedDescription=Cannot Decode}

Getting the above error when trying to start writing with an AVAssetWriter. This only occurs on iphone 5s, and only occurs sometimes. The most reproducible case is when we move from a VC with an AVPlayer that is playing media straight to the VC that handles the recording. The same VC with the recorder works correctly with the same settings when not navigating from the VC with the AVPlayer. What might cause this error and where can I look to fix this?

The asset writer code is part of the SCRecorder pod: https://github.com/rFlex/SCRecorder https://github.com/rFlex/SCRecorder/blob/master/Library/Sources/SCRecordSession.m


Solution

  • We solved this after finding that the audio sample rate was being changed, causing this error. We recheck the audio sample rate prior to recording and correct it if it has for some reason been changed.