Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot play certain videos

I'm trying to play movies on the Android device from our server. It is not a media server, just a regular Apache server. We use the same API to access the videos on the iPhone and it works fine.

On the Android device, certain videos work, and others do not. They were all created the same way, except the majority of the ones that don't work are composed of still images and audio.

We have tried re-encoding them with Videora, and tried hinting them with MP4Box. All of the videos play perfectly fine when stored on the SD card. We have also tried first downloading the video from the server to the SD card, saving it as a file, and then playing it from the file, but this does not work either.

Help would be amazing. I am massively confused. Thanks.

Edit - Logcat:

01-19 08:19:12.669: DEBUG/MediaPlayer(1878): Couldn't open file on client side, trying server side

01-19 08:19:14.119: INFO/ActivityManager(1172): Displayed activity com.myproject/.VideoClass: 1966 ms (total 1966 ms)

01-19 08:19:15.779: ERROR/PlayerDriver(1071): Command PLAYER_INIT completed with an error or info UNKNOWN PVMFStatus

01-19 08:19:15.789: ERROR/MediaPlayer(1878): error (200, -32)

01-19 08:19:15.789: ERROR/MediaPlayer(1878): Error (200,-32)

01-19 08:19:15.789: DEBUG/VideoView(1878): Error: 200,-32

01-19 08:19:15.849: WARN/PlayerDriver(1071): PVMFInfoErrorHandlingComplete

UPDATE: Here a pastebin of the video analysis for three different videos. The first streams on the app from the server. The second video will not stream, but can be downloaded then played from the device. The third can neither be streamed or downloaded to be played. http://pastebin.com/9qChSkFz

WTF.

like image 220
Jai Avatar asked Jan 18 '11 19:01

Jai


People also ask

Why are certain videos not playing?

Accumulated data in the form of cache and cookies tend to prevent videos from playing on Chrome. Get rid of these corrupted cookies, history, passwords, and any other browsing data, to free up space for new videos to load and play.

Why does my phone not play certain videos?

The media player is outdated. Android OS is not updated. The video is not downloaded completely from the source. Your mobile SD card is corrupt.


1 Answers

I've run into the same problem, and after initially giving up, I've found a solution.

I stumbled upon the following page http://developer.android.com/guide/appendix/media-formats.html which states:

For 3GPP and MPEG-4 containers, the moov atom must precede any mdat atoms, but must succeed the ftyp atom.

After doing some digging, I found out this is exactly the problem. Video recorded from certain Android phones (I believe pre 2.3) places the moov atom at the end of the file. This makes them un-streamable. Some googling will show you this is a common problem with MP4 files and flash players in particular, since they were made to stream video.

There is even a specific error code for this in MediaPlayer (but I did not see these logged) MediaPlayer#MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK.

My solution is to run the video file through an external tool to move the moov atom to the start. I ended up using MP4Box: http://gpac.wp.institut-telecom.fr/mp4box/ and the command

MP4Box -inter 500 original.mp4 -out fixed.mp4

Hope that helps someone else!

like image 53
jonson Avatar answered Sep 30 '22 15:09

jonson