Android: What video format/encoding should I use to support most of the android devices

蓝咒 提交于 2019-12-07 13:25:14

问题


I have a collection of video clips which user should be able play from inside my app (not external video player). I am using VideoView with MediaController. Everything works as expected on my Desire HD and Nexus S (both running Android 2.3.3). However they won't play on order devices. I get "Sorry, this video cannot be played" error message.

All videos are mp4, encoded with H.264, 720w/480h, 25fps. I have also used H.263(3gp) but with no luck.

I want to support as many Android devices as possible. At least starting from 2.1

Does any one had the same problems? What videos are you using in your apps? Thanks for help!


回答1:


You can use some third part media library extend your app's supported format, here is a good one Vitamio:

Media formats
Many audio and video codecs are packed into Vitamio beside the default media format built in Android platform, some of them are listed below.

divx/xvid
wmv
flv
ts
rmvb
mkv
mov
m4v
avi
mp4
3gp

Shouldn't be too hard to integrate and use it into your project, though I don't know its performance running on old Android device like 2.1:

Vitamio provides the similiar interfaces with Android default MediaPlayer framework. If you're using android.media.MediaPlayer in your project, just grab the vitamio.jar from above, then add it to your project's libs, and replace the import of android.media.MediaPlayer with io.vov.vitamio.MediaPlayer.

Hope this help.




回答2:


Google has a list on there site : http://developer.android.com/guide/appendix/media-formats.html

3GPP & MP4 seem the most compatible

It also lists the mandatory profiles so you should be able to get something going.

TBH until later revisions of Android video playback compatibility is poor unless you bundle a decoder in your app. (I bought a software h264 decoder to fall back upon). One of the reasons I gave up with game writing for Android , still good for apps revenue though ;-)



来源:https://stackoverflow.com/questions/8415709/android-what-video-format-encoding-should-i-use-to-support-most-of-the-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!