简体   繁体   English

我应该如何选择在Web,Android和iOS上播放的视频格式?

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

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. 我正在开展一个视频共享项目,并想知道如果有一种视频格式与Web,Android和iOS上的大多数播放器兼容。

The app will work like this: 该应用程序将如下工作:

  1. users can take videos from mobile devices (iOS and Android) 用户可以从移动设备(iOS和Android)拍摄视频
  2. other users can play videos on mobile devices (iOS and Android) and web browsers. 其他用户可以在移动设备(iOS和Android)和网络浏览器上播放视频。

I am not familiar with different video formats. 我不熟悉不同的视频格式。 I noticed that .mov and .mp4 are used in iOS. 我注意到.mov和.mp4在iOS中使用。 But I assume .mov cannot be played on Android and web browsers except Safari? 但我认为.mov不能在除Safari之外的Android和Web浏览器上播放? Could anyone give a hint? 任何人都可以提示吗?

From Android Developer - Supported media formats , 来自Android Developer - 支持的媒体格式

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 Developer Library - Media Layer

iOS supports many industry-standard video formats and compression standards, including the following: iOS支持许多行业标准视频格式和压缩标准,包括:

  • 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视频,高达1.5 Mbps,640 x 480像素,每秒30帧,H.264基线配置文件的低复杂度版本,AAC-LC音频高达160 Kbps,48 kHz,立体声音频,.m4v, .mp4和.mov文件格式

  • 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 H.264视频,高达768 Kbps,320 x 240像素,每秒30帧,基线配置文件高达1.3级,AAC-LC音频高达160 Kbps,48 kHz,立体声音频,.m4v,.mp4和。 mov文件格式

  • 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 MPEG-4视频,高达2.5 Mbps,640 x 480像素,每秒30帧,简单配置文件,AAC-LC音频高达160 Kbps,48 kHz,立体声音频,.m4v,.mp4和.mov文件格式

  • 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), 此外,从MDN - HTML音频和视频元素支持的媒体格式 (HTML5中的<video>标签),

  • <video> : VP8 and Vorbis in WebM <video> :WebM中的VP8和Vorbis
  • <video> : VP9 and Opus in WebM <video> :WebM中的VP9和Opus
  • <video> : Streaming WebM via MSE <video> :通过MSE流式传输WebM
  • <video> : Theora and Vorbis in Ogg <video> :Ogg的Theora和Vorbis
  • <video> : H.264 and MP3 in MP4 <video> :MP4中的H.264和MP3
  • <video> : H.264 and AAC in MP4 <video> :MP4中的H.264和AAC
  • <video> : FLAC in MP4 <video> :MP4中的FLAC

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). 从所有数据来看,似乎.mp4 (确切地说, H.264视频,AAC音频,MPEG-4 )是这里的选择,因为它在所有平台(iOS,Android,网络浏览器)中都受支持。 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. 但是,请注意,您仍然需要检查每个平台(不同版本的Android,不同的Web浏览器)上的兼容性问题,这在每个站点上都有说明。

Adding more info from Andrew T.'s answer. 添加更多信息来自Andrew T.的回答。

To set the parameters from Andrew's conclusion: 从Andrew的结论中设置参数:

// 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...!!! 希望能帮助到你...!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 跟踪播放视频的持续时间-Web,iOS和Android - Track time duration for which video was played - Web, iOS and Android 从Android屏幕录像机捕获的视频无法在Web浏览器上播放 - Video captured from Android screen recorder can not be played on web browser 如何选择将播放SC 2服务器中的哪个SID? - How can I choose which SID from a SC 2 server will be played? 在Android中播放视频后如何停止视频播放器 - how to stop video player after it has played a video in android 如何获得当前播放视频的当前时间? 从VLC Player for Android - How could I get the current time of the currently played video? from VLC Player for Android Android抱歉,此视频无法播放 - Android Sorry, this video cannot be played videoView Android无法播放视频 - Video can not be played by videoView Android 我应该在Android中录制什么格式才能在iOS中播放 - What format should I record in android to play in ios 如何使用Http流保存在VideoView中播放的视频 - How can I save video played in VideoView using Http streaming 对于要在 Android 应用程序中使用的普通图像,我应该选择什么“图标类型”? 我应该如何将它们添加为 ImageViews? - What "Icon Type" should I choose for normal images to be used in an Android app? How should I add these as ImageViews?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM