Android: What video format/encoding should I use t

2019-05-11 06:55发布

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!

2条回答
太酷不给撩
2楼-- · 2019-05-11 07:30

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.

查看更多
Anthone
3楼-- · 2019-05-11 07:38

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 ;-)

查看更多
登录 后发表回答