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

后端 未结 2 1846
逝去的感伤
逝去的感伤 2021-01-30 15:04

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

相关标签:
2条回答
  • 2021-01-30 15:25

    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...!!!

    0 讨论(0)
  • 2021-01-30 15:40

    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.

    0 讨论(0)
提交回复
热议问题