AVAssetWriter error -3000 with underlying error -12143

Hello,


We encountered this issue when starting to write a file with the AVAssetWriter class. This happens rarely and trying a few seconds later works fine.


I could not find any information about those error codes.


The error's code is -3000 with the localizedDescription "Cannot create file" and the underlying error has the code -12143 with the same localizedDescription.


Any help as to the meaning of those codes and why the creating actually failed is much appreciated.


Thank you

Valérian

Replies

The -12143 error comes from FigAssetWriterCreateWithURL in MediaToolbox, which happens when CMByteStreamCreateForFileURL fails, likely the result of open() failing in _FigFileForkOpenMainByCFURL. So why open() fails is impossible to know specifically, but the most common reason is simply permissions. It'd be nice if the EPERM would actually bubble up.


What you should do in the mean time, is look for NSOSStatusErrorDomain -12143 errors, then write an empty NSData to the given file URL and if it fails, display that NSError instead as it will be more specific.