NOTICE: FORUMS MOVING

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

roger

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 http://videojs.com/ 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 (http://diveintohtml5.org/video.html) 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,

Roger

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 videojs.com 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. 2 Posted by roger on 08 Sep, 2011 11:21 PM

    roger's Avatar

    OK, I reduced the code generated at http://videojs.com/embed-builder/ 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 ?

    R.

  2. 3 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 ;-)

    R.

  3. 4 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. 5 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 !

    Regards,

    R.

  5. 6 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,
    K

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

    huberte's Avatar

    same pb here. htacess protected wordpress blog

  7. 8 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. 9 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. 10 Posted by dezzadk on 03 Jul, 2012 11:42 AM

    dezzadk's Avatar

    Try to copy the HTML-source from the mainpage of http://video.js.com/ ..

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

  10. 11 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,
    Dave

  11. 12 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. 13 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 http://.....com/video.mp4 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?

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

Generic

? 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

30 Jul, 2014 03:25 AM
28 Jul, 2014 08:32 AM
27 Jul, 2014 07:35 PM
23 Jul, 2014 04:00 PM
21 Jul, 2014 10:07 PM

 

18 Jul, 2014 10:13 PM
17 Jul, 2014 09:04 PM
15 Jul, 2014 02:53 PM
09 Jul, 2014 03:01 AM
08 Jul, 2014 08:01 PM
07 Jul, 2014 04:57 PM