I'm trying to upload a recorded video file and regular video file from the photos gallery on Mux server. I am receiving this error message:
Error:
The input file was not a valid video or audio file [error type: invalid_input] all the time.
I tried uploading via a raw request and Alamofire. Also, I tried encoding the file to MP4 before sending it.
The code looks something like this:
func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let videoURL = info[UIImagePickerController.InfoKey.mediaURL] as! URL
AF.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append(videoURL, withName: "video", fileName: "video.mov", mimeType: "video/mov")
}, with: urlRequest).response { (response) in
}
}
I tried converting videoURL
to data using:
Data(url: videoURL)
InputStream(url: videoURL)
I know that in cURL I should have --data-binary 'Video.mp4'
, which, on Android works, but I don't know how to convert the file to data-binary (byte) on iOS.