Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Video View not playing MP4 file on some devices

In my app I need to play videos from sdcard. Now it works fine on Galaxy S,Galaxy Tab2, But on some chinese tab Like "Giada" It is not working at all.

I have 4 different activities to play videos like. First activity plays a menu video which has navigation link to other activity. Problems I am facing.

  1. First Video plays properly but looping failed and app closed.
  2. If I navigate to other activity to play another video it says "Can't Play Video" and closed Some time it plays same video but not complete and closed app in between.

Video Extension: MP4 Resolution : 1024x600 Playing From : SDCard.

Target Tab Specification.

Resolution : 1024x600 Android :4.1

Tried with Video View and SurfaceView.

Help me out any help will be regreted.

like image 809
sandy Avatar asked Oct 03 '13 05:10

sandy


People also ask

Why do some of my MP4 files not play?

Reason 1: The media player you are using is not compatible with the format. Reason 2: There could be a codec issue. Reason 3: The MP4 file that you have downloaded could be broken. These are the most common reasons why you may end up looking for how to fix corrupt video files MP4 solutions.

Why won't MP4 play on my Android?

Do you have an MP4 video file on your Android that won't play? Android phones and tablets will open most MP4 files in their default player app. However, if you have an MP4 file or attachment that won't open, you'll need to use a third-party app. Luckily, you can easily install and use VLC in a few simple steps.

Will MP4 play on all devices?

MP4 is the most widely used format. It can be played on a variety of devices, including PC, Mac, TV, iPhone, Android, Xbox, PS5, and more.


1 Answers

The answer to this question will never be consistent across all devices or across all videos.

Whether a given video file will play in a given player depends on three things:

  • The video container format (file type).
  • The codecs the video (and potentially audio) streams are encoded with
  • Your player's support for that combination of container format and codec

The codec and player/device support for it is almost certainly the cause of the inconsistent results you've seen. (A codec, if you didn't know, is basically a repeatable mathematical formula that tells your system how to turn bits and bytes packed into a file into moving pictures(and back again, for that matter))

There are a large variety of video codecs in the video files floating around out there. Support for these codecs is wildly inconsistent just due to the history of video distribution. Many devices won't support streams encoded with certain codecs. There are a variety of reasons for this, but the most common are obscurity or licensing costs.

For example, up until a few years ago, almost everything was encoded in an .FLV container with an On2 VP6/VP7/VP8 codec. This is causing headaches today because while On2 owned these codecs, they kept a tight rein on the licenses. That didn't relax until .FLV had already begun to lose relevance, and so there is not a whole lot of (legitimate) software out there that can work with On2-encoded content.

What all of this means is that there is no silver bullet. All video will never run on all devices, at least not without the aid of video players that install and use their own codecs to decode the streams.

Needless to say, this does not include the libraries provided to you and your end users by the factory-installed Android libraries.

So, what do you do? Well, short of producing a video player that carries its own codecs, you can most effectively address the problem with a two-step approach:

  1. Target specific devices that you want your application to work on
  2. Encode your content to use use a video codec that works on all the devices you want to target. You may need to produce two copies of your video if you find that there is no codec that works across all devices you plan to support.

Today, the widest support is available with an MP4 container and a video stream encoded with the H.264 (AVC) codec. As I said, there is no silver bullet, and H.264 support is not universal by any means, but this one format will be playable more potential users than any other single choice you could make, due to its popularity and wide support in modern desktop and mobile environments.

Some tools you may find helpful:

  • MediaInfo will let you peek inside MPEG-flavored video containers to see what codecs are in use. This will be helpful in determining which devices are having trouble with which codecs.
  • FFmpeg is an encoding application that can convert your content to MP4/H.264
  • Android Supported media formats List of supported media audio/video formats.

Good luck!

like image 194
Umopepisdn Avatar answered Oct 26 '22 23:10

Umopepisdn