Thank you for visiting and participating in the Video.js forums. We are currently moving the forums to Stack Overflow and GitHub Issues. If you have a question or need help with Video.js, please post your question on Stack Overflow and add the tag 'video.js'. If you've found a specific bug in Video.js, please submit it in the issues tracker.

You can read more about this move on the blog.

Playing MP4 on Android using VideoJS

roger's Avatar


07 Sep, 2011 09:34 PM

OK, I am testing the running of a video using VideoJS. All is well until I try an Android (v2.2) using the standard browser. When I press "play", I briefly get "Loading video", quickly followed by a pop-up that says "Cannot play video - Sorry, this video cannot be played." What baffles me is that if I go to the demo on on the same device, then it plays !

So let me think: this device does NOT have Flash installed, so I assume that for the VJS page, its demo must be natively playing the H264 (MP4) file because, (as I understand it) Android 2.2 cannot play webm or ogv ... please correct me if I'm wrong !

I have tried to follow the suggestions in the excellent "Dive Into HTML5" by Mike Pilgrim ( using my FLV file as input, including removing the "type" parameter from the H264 source tag - no difference.

So I assume that it must be down to how I am encoding the H264 file. I have tried the Miro & Handbrake settings suggested by Mike Pilgrim - no difference. I have a trial account an Zencoder. This has, by miles, the biggest range of parameter settings I have ever seen and I have tried to work out the right values to encode my file, but my efforts so far have been in vain.

So, can somebody please tell me what parameters the H264 clip (oceans-clip.mp4) uses ? Specifically, what are the must-haves for Android.

Or if it is something else entirely, please point me in the right direction !

Many thanks,


PS: I should add that I have tried hosting my file on my own domain AND Amazon S3. In both cases, I have been at pains to ensure the correct permission for the files.

PPS: Update: today, in my oceans-clip HTML, I cut out practically everything from my generated VIDEO tag except the SOURCE tag for the MP4 file ... and it still played. This convinces me even more that it must be to do with the encoding.

PPPS: When trying a video file hosted on my domain, I amended the MIME type in .htaccess (as recommended in Mike Pilgrim's book), though it made no difference. The oceans-clip seems to have no problem so either the site also has its MIME types correct OR this piece of advice is irrelevant. If it's the former, I wonder whether having the source on Amazon means that we don't have that kind of control any more. Just a thought ...

  1. 1 Posted by roger on 08 Sep, 2011 11:21 PM

    roger's Avatar

    OK, I reduced the code generated at to just one VIDEO and one SOURCE (mp4) tag with no fallback and it works perfectly on the Android. Substitute my file (on my server or S3) and it fails as described.

    My latest thinking is this: if the demo file (mp4) works but one of mine does not, what else is different ? Answer: the location it's served from. Put the demo file on my box and point at that and I get the error - same file, different location.

    I have the following in the ,htaccess file of the directory where the file is stored:
    AddType video/ogg .ogv
    AddType video/mp4 .mp4
    AddType video/webm .webm
    Everybody has read access whether on my server or S3.

    This IS driving me nuts. There must be some difference on the two server set-ups but I don't know enough and/or can't figure it. Any ideas please ?


  2. 2 Posted by roger on 09 Sep, 2011 04:49 PM

    roger's Avatar

    OK, this is going to be one of those "I've got it working ... kind of, sort of ..." threads !

    After sleeping on this, I decided to try moving the test file to another hosting account that I have (where I have what I'll call "domain number 2") and of course changing the SOURCE tag to match ... It worked !

    Now let's try it on another domain ("domain number 3"), this time on the same hosting account as the original "test" domain ("domain number 1"). Ditto. Back to "domain 1": no dice. Weird !

    So I AM right in assuming that there is something odd and/or different about the "test" domain though quite what it is, I really don't know. With the others, I didn't even check or set MIME types, they just worked. If anybody has any ideas on what's going on, I'd really like to hear them.

    To put the cherry on the cake, I turned my attention to having the file on Amazon S3 ... no joy at first, so I used S3Fox to check that the file had permission for reading on the Access Control List. I had also been using this to get the URL to put in my code. I copied and pasted this again and noticed that it was giving me the "https" method by default ! Removing the last letter gives me a happy end to my working week :-)

    I still have no idea how or why my test domain is different from the others, so I would still like to hear any ideas on that score. But I can now play my MP4 videos on my cheapo Android without Flash using VideoJS :D

    If you have been, thanks for listening ;-)


  3. 3 Posted by Nikos Pachtas on 14 Sep, 2011 08:12 PM

    Nikos Pachtas's Avatar

    Dear Roger,

    is not a matter of domain, it's not a matter of server, of .htaccess or anything else. I downloaded the example video (oceans-clip.mp4) on my server and it worked fine, although my miro encoded mp4 video didn't work.

    I used Zencoder with default settings (and an youtube flv as input) to encode a 5sec mp4 video from my flv original (watermarked by Zencoder) and it worked fine too. So the important thing to do is use Zencoder for encoding to mp4. Anything else is a dead end.

    Maybe this is a way to make profit for Zencoder (after all the VideoJS is copyrighted by Zencoder)

  4. 4 Posted by roger on 15 Sep, 2011 09:41 AM

    roger's Avatar

    Hi Nikos, thanks for that but my experiments suggest that is must be a server thing. Consider ... the very same file works when placed on 2 different domains that I control and these are on different hosting accounts. When I try it on the original domain (which is on the same account as one of the two working domains), it won't work. The ONLY difference is the location where it resides, so it must be something to do with the configuration of that domain because the same file is being used. I have also with a couple of different files including one that I encoded myself using PiTiVi and one using the Zencoder test service - it even happens with the oceans clip too !

    As it happens, the problem domain is my "test" domain, and now I know about the problem, I use Amazon S3 (http not https !) and all is well. Unfortunately, I don't have the time to do an exhaustive investigation of the differences in the server configurations, but if anybody happens to know the answer, I'd be happy to hear it !



  5. 5 Posted by karstor on 17 Feb, 2012 02:23 PM

    karstor's Avatar

    Hi Roger,

    I had exactly the same problem but using plain simple html5 without any js libraries. Not sure whetehr this is helpful, but speaking of .htaccess
    I had my site in a password protected area of my webspace. While everything played back fine in all the browsers on the desktop, I continuously got the "Sorry, cannot play this file" message on my android browsers (Android 2.3).
    Playing back files from other domains was fine.
    After pulling my hair for hours I moved the videos outside the .htaccess protected area and tadaaa: they worked as expected.
    In case this does not apply to you I still would be interested in hearing what your solution to the problem was (if you ever found one).

    all the best,

  6. 6 Posted by huberte on 19 Apr, 2012 02:55 AM

    huberte's Avatar

    same pb here. htacess protected wordpress blog

  7. 7 Posted by Jero on 08 Jun, 2012 02:32 AM

    Jero's Avatar

    Same problem here. I have donwloaded the oceans-clip.mp4 fileto my computer and I have hosted in a local server (Xampp). It works, but my own mp4 file still doesn't work in that way also. I will try Zencoder now. I think it could be the encoding as Nikos says. I will post what happen.
    Sorry for my bad english.

  8. 8 Posted by Jero on 08 Jun, 2012 02:48 AM

    Jero's Avatar

    I have tried Zencoder, too complicated for me :D. But I found another solution. With the Miro Video Converter, set the output to one of the Android devices. The resulting file will be an mp4 ready to be played on an Android device. I hope it work for you.

  9. 9 Posted by dezzadk on 03 Jul, 2012 11:42 AM

    dezzadk's Avatar

    Try to copy the HTML-source from the mainpage of ..

    And when you attach V('yourVideo') from JavaScript, do it in a bottom script-block ..

  10. 10 Posted by upgradingdave on 05 Sep, 2012 06:08 PM

    upgradingdave's Avatar

    Same Problem. I generate my mp4s using H.264 using Camtasia Studio and upload to amazon s3.

    If I use ssl (https) as the video source url, it fails. If I use http it works.

    For example this works on android:

    This doesn't work:

    So, seems that android doesn't like https as video source for some reason.

    Hope this helps,

  11. 11 Posted by manu on 08 Apr, 2014 08:06 AM

    manu's Avatar

    thanks karstor!
    had a similar issue, solved when I removed password protection.

  12. 12 Posted by Le-roy on 27 Jun, 2014 04:38 AM

    Le-roy's Avatar

    Did you try making your URL absolute? I had trouble with relative paths but as soon as I put the instead of just a relative directory path it worked. Maybe that is also why you are seeing different domains working? When you try on the same server you are writing the source as relative path?

  13. 13 Posted by Nico Engler on 24 Sep, 2015 03:49 AM

    Nico Engler's Avatar

    Hi, did anyone find the cause for this? I am experiencing the same problem for my self hosted file and I can't get it working on my phone. I already tried absolute paths but that didn't make any difference. I guess I will try the ocean file tomorrow and see if it works.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

29 Oct, 2015 05:55 AM
15 Oct, 2015 03:50 AM
24 Sep, 2015 10:01 AM
24 Sep, 2015 03:49 AM
18 Jul, 2015 11:58 AM


04 Jul, 2015 10:27 AM
17 Jan, 2015 12:13 PM
04 Dec, 2014 02:39 AM
27 Nov, 2014 01:11 PM
25 Nov, 2014 05:34 PM
20 Nov, 2014 04:11 PM