Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I choose a video format to be played on Web, Android & iOS?

Tags:

I am working on a video sharing project and wonder what if there's a video format that is compatible with most players on Web, Android & iOS.

The app will work like this:

  1. users can take videos from mobile devices (iOS and Android)
  2. other users can play videos on mobile devices (iOS and Android) and web browsers.

I am not familiar with different video formats. I noticed that .mov and .mp4 are used in iOS. But I assume .mov cannot be played on Android and web browsers except Safari? Could anyone give a hint?

like image 649
cannabis Avatar asked Oct 03 '14 03:10

cannabis


2 Answers

From Android Developer - Supported media formats,

Type  | Format /  | Supported File Type(s) /
      | Codec     | Container Formats
------+-----------+----------------------------------------------------------
Video | H.263     | 3GPP     (.3gp)
      |           | MPEG-4   (.mp4)
      +-----------+----------------------------------------------------------
      | H.264 AVC | 3GPP     (.3gp)
      |           | MPEG-4   (.mp4)
      |           | MPEG-TS  (.ts, AAC audio only, not seekable, Android 3.0+)
      +-----------+----------------------------------------------------------
      | H.265 HEVC| MPEG-4   (.mp4, Android 5.0+)
      +-----------+------------------------------------------------------
      | MPEG-4 SP | 3GPP     (.3gp)
      +-----------+----------------------------------------------------------
      | VP8       | WebM     (.webm)
      |           | Matroska (.mkv, Android 4.0+)
      +-----------+----------------------------------------------------------
      | VP9       | WebM     (.webm)
      |           | Matroska (.mkv, Android 4.0+)

On the other hand, from iOS Developer Library - Media Layer,

iOS supports many industry-standard video formats and compression standards, including the following:

  • H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

  • H.264 video, up to 768 Kbps, 320 by 240 pixels, 30 frames per second, Baseline Profile up to Level 1.3 with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

  • MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

  • Numerous audio formats, including the ones listed in Audio Technologies

Also, from MDN - Media formats supported by the HTML audio and video elements (<video> tag in HTML5),

  • <video>: VP8 and Vorbis in WebM
  • <video>: VP9 and Opus in WebM
  • <video>: Streaming WebM via MSE
  • <video>: Theora and Vorbis in Ogg
  • <video>: H.264 and MP3 in MP4
  • <video>: H.264 and AAC in MP4
  • <video>: FLAC in MP4

From all data, it seems that .mp4 (to be exact, H.264 video, AAC audio, in MPEG-4) is the choice here, since it's supported in all platforms (iOS, Android, web browser). However, take note that you still have to check for compatibility issues on each platform (different version of Android, different web browser), which is explained on each site.

like image 118
Andrew T. Avatar answered Oct 14 '22 22:10

Andrew T.


Adding more info from Andrew T.'s answer.

To set the parameters from Andrew's conclusion:

// To Set Audio Encoder: AAC
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

// To set Video Encoder: H264
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

// To set Output Video format: mp4
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

Hope it helps...!!!

like image 31
Chintan Soni Avatar answered Oct 14 '22 20:10

Chintan Soni