0

I am using UIImagePickerController to pick videos in a messaging app. These videos can then be played back on either an iOS app, Android app or Web app. I am using the code below.

let picker = UIImagePickerController()
picker.delegate = self
picker.mediaTypes = ["public.image", "public.movie"]
picker.videoQuality = UIImagePickerControllerQualityType.typeMedium 
if #available(iOS 11.0, *) {
    picker.videoExportPreset = AVVideoProfileLevelH264Baseline30
}

This works fine and the video message sends and plays back fine on iOS and web but when playing back in an Android VideoView I get a "Can't play this video" message. The video is definitely being saved to the Android device in the correct location as I can pull it from there using Android Device Monitor and see that it is definitely h264 but there is something about the file the Android VideoView doesn't like.

What am I missing to make these videos picked on iOS play on an Android device? I'd really rather not transcode them on a server because that will massively slow down the message delivery time.

Thanks for your help

365SplendidSuns
  • 3,175
  • 1
  • 21
  • 28

1 Answers1

-1

To answer my own question in case anyone else needs it.. The iOS file was actually a .MOV even though it was encoded with h264 and saved as .mp4.

I used the function from this post to convert the .MOV to mp4 and problem solved.

Swift - How to record video in MP4 format with UIImagePickerController?

365SplendidSuns
  • 3,175
  • 1
  • 21
  • 28