I'm trying to upload mp4 file to Firebase, but I'm getting this response:
Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={object=video/viedo.mp4, bucket=********.appspot.com, ResponseBody=Can not finalize upload. Current size is 1385472. Expected final size is 1596602.
I don't have any problems with uploading mov files. Can this be connected with fact that before I upload my mp4 file, I create it from mov file programmatically as in MOV to Mp4 video conversion iPhone Programmatically using AVURLAsset (conversion is ok as I watch file using AVPlayer) ?
Edit: code for function that create mp4 file from mov file
private func encodeVideo(videoURL: URL, completion: @escaping (_ url: URL?) -> ()) {
let avAsset = AVURLAsset(url: videoURL, options: nil)
//Create Export session
exportSession = AVAssetExportSession(asset: avAsset, presetName: AVAssetExportPresetPassthrough)
if exportSession == nil {
return
}
let documentsDirectory2 = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let filePath = documentsDirectory2.appendingPathComponent("rendered-Video.mp4")
deleteFile(filePath: filePath)
exportSession!.outputURL = filePath
exportSession!.outputFileType = AVFileTypeMPEG4
exportSession!.shouldOptimizeForNetworkUse = true
let start = CMTimeMakeWithSeconds(0.0, 0)
let range = CMTimeRangeMake(start, avAsset.duration)
exportSession!.timeRange = range
exportSession!.exportAsynchronously(completionHandler: {() -> Void in
switch self.exportSession!.status {
case .failed:
completion(nil)
print("%@",self.exportSession!.error ?? "error saving mp4")
case .cancelled:
completion(nil)
print("Export canceled")
case .completed:
completion(filePath)
default:
completion(nil)
break
}
})
}
I also sometimes get respone
ResponseBody=Can not finalize upload. Current size is 1854819. Expected final size is 1626331.