Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What video format will play on all Android devices?

Tags:

Android can play a variety of video formats, but I need to choose one format that will work on all devices.

Do all Android 2.3 devices support exactly the same formats? i.e. if the format will play in the emulator, does that mean it will also play on all hardware? Or do different devices support different formats depending on what decoder chips they have?

If they are all the same then obviously the best format is H.264 at a high bitrate and resolution. If not, then what is the best codec/bitrate/resolution that will play on 90% of devices? Do Google provide some way of querying the device's video capabilities and choosing an appropriate format?

like image 558
Richard Avatar asked Feb 23 '11 21:02

Richard


People also ask

Which video format is supported by all phones?

MPEG-2 TS media files only.

Which video format is best for all devices?

AVI (Audio Video Interleave) works with nearly every web browser on Windows, Mac and Linux machines. Developed by Microsoft, AVI offers the highest quality but also large file sizes. It is supported by YouTube and works well for TV viewing.

Which video format is best for mobile phones?

Video - We recommend using MP4 video (or M4V) for compatibility with both iOS and Android.

Which media format is not supported by Android?

The AVI format is not supported on android devices. Most of the android users are looking for the easy way to play the AVI files on their android tablets and smartphones. In Android Mobile device you can't play the AVI file without converting them into the supported format.


1 Answers

After testing on a lot of devices(for the video splashscreen of a very popular app). My recommendations are:

video codec : H.264  file format: .mp4 video bitrate: 256kbps video frame/second: 24 

Note:My video has no sound!!

But even with this recommendation, some videos will not work because of its resolution. So i create a tricky code: I embed all my videos for all the density in my raw folder, added an setOnErrorListener to my VideoView and i try to launch a smaller video each time an error occured.

This is my raw folder:

raw/    splashmdpi.mp4    splashhdpi.mp4    splashxhdpi.mp4 

and this is my java code:

int densityoffset = 0; VideoView video = new VideoView(this);  video.setOnPreparedListener(new OnPreparedListener() {              @Override                  public void onPrepared(MediaPlayer mp) {                     video.start();                     }  }  video.setOnErrorListener(new OnErrorListener() {             @Override             public boolean onError(MediaPlayer mp, int what, int extra) {                 densityoffset++;                 String suff = getDensitySuffix(getContext(), densityoffset);                 video.setVideoPath("android.resource://com.example.packagename/raw/splash"+suff);                 if(offset>5)                     return false;                 else                       return true;                 }             });  String suff = getDensitySuffix(this,offset); video.setVideoPath("android.resource://com.example.packagename/raw/splash"+suff);  private String suffix[]={"ldpi","mdpi","hdpi","xhdpi"};  /** *Return the suffix concerning your device less offset value **/ private String getDensitySuffix(Context ctx, int offset){         int dens = 2;         int d = getContext().getResources().getDisplayMetrics().densityDpi         if(d==DisplayMetrics.DENSITY_LOW)             dens = 0;         else             if(d==DisplayMetrics.DENSITY_MEDIUM)                 dens = 1;             else                 if(d==DisplayMetrics.DENSITY_HIGH))                     dens = 2;                 else                     if(d==DisplayMetrics.DENSITY_XHIGH))                         dens = 3;            return suffix[Math.max(0, dens-offset)];     } 
like image 191
VinceFR Avatar answered Sep 28 '22 03:09

VinceFR