Posts

Post not yet marked as solved
6 Replies
Hi @all,I am facing the same issues in ios 13.3 in real device it is working in ios 13.2 simulator but gives below error.Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-17508), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x2816d11d0 {Error Domain=NSOSStatusErrorDomain Code=-17508 "(null)"}}Here is my code I want to convert .mov file to mp4.class func encodeVideo(at videoURL: String, completionHandler: ((URL?, Error?) -> Void)?) { let avAsset = AVURLAsset(url: URL.init(fileURLWithPath: videoURL), options: nil) let startDate = Date() //Create Export session guard let exportSession = AVAssetExportSession(asset: avAsset, presetName: AVAssetExportPresetPassthrough) else { completionHandler?(nil, nil) return } //Creating temp path to save the converted video let filename = "Video_\(Date().timeIntervalSince1970).mp4" // Below Folder Path used tor getting directory path let strfilePath = (FolderPath.temporaryDirectory.getDirectoryPath as NSString).appendingPathComponent(filename) let filePath = URL.init(fileURLWithPath: strfilePath) //Check if the file already exists then remove the previous file if FileManager.default.fileExists(atPath: filePath.path) { do { try FileManager.default.removeItem(at: filePath) } catch { completionHandler?(nil, error) } } exportSession.outputURL = filePath exportSession.outputFileType = AVFileType.mp4 exportSession.shouldOptimizeForNetworkUse = true let start = CMTimeMakeWithSeconds(0.0, preferredTimescale: 0) let range = CMTimeRangeMake(start: start, duration: avAsset.duration) exportSession.timeRange = range exportSession.exportAsynchronously(completionHandler: {() -> Void in switch exportSession.status { case .failed: print(exportSession.error ?? "NO ERROR") completionHandler?(nil, exportSession.error) case .cancelled: print("Export canceled") completionHandler?(nil, nil) case .completed: //Video conversion finished let endDate = Date() let time = endDate.timeIntervalSince(startDate) print(time) print("Successful!") print(exportSession.outputURL ?? "NO OUTPUT URL") completionHandler?(exportSession.outputURL, nil) default: break } }) }