I have these code snippets to take an existing video file, write one additional track to it and then write the result to a new file.
let movie = AVMovie(url: fromFileUrl)
let mutableMovie = movie.mutableCopy() as! AVMutableMovie
(removed some code here that adds another track to the mutableMovie)
let exporter = AVAssetExportSession(
asset: mutableMovie,
presetName: AVAssetExportPresetPassthrough
)
exporter!.outputFileType = .mov
exporter!.outputURL = newFilePath
exporter!.exportAsynchronously {...
This works great up to IOS 16, but from IOS 17 beta I get the following errors in the console of XCODE 15 beta 5
<<<< AVAsset >>>> +[AVURLAsset _getFigAssetCreationOptionsFromURLAssetInitializationOptions:assetLoggingIdentifier:figAssetCreationFlags:error:]: AVURLAssetHTTPHeaderFieldsKey must be a dictionary
<<<< AVError >>>> AVLocalizedErrorWithUnderlyingOSStatus: Returning error (NSCocoaErrorDomain / 257) status (-12 203)
The export then fails with the following error:
Error Domain=NSCocoaErrorDomain Code=257 \"The file couldn’t be opened because you don’t have permission to view it.\" UserInfo={NSUnderlyingError=0x280d15770 {Error Domain=NSOSStatusErrorDomain Code=-12203
Any ideas on how I can solve this? Or is it just a bug in IOS 17 beta that I have to wait for being fixed?
Tested on iOS 17.0 (21A5291h)