Google Chrome浏览器不想使用mediaelement.js播放mp4 [英] Google Chrome does not want to play mp4 using mediaelement.js

查看:309
本文介绍了Google Chrome浏览器不想使用mediaelement.js播放mp4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用我网站上的最新mediaelement.js播放html5视频。
谷歌浏览器中有一些奇怪的东西。
他播放一个视频,但不想播放mp4格式的其他视频,并且不会回退到webm。
这两个视频都用ffmpeg转换为这个参数:

  ffmpeg -i input.mov -acodec libfaac -ab 96k -vcodec libx264 -vpre slow -vpre main -level 21 -refs 2 -b 345k -bt 345k -threads 0 -s 640x360 output.mp4 

此外,第一个视频通常无需使用media4lement.js库以mp4格式播放,第二个视频转换为webm格式。



来自的网页http://random.net.ua/video_test/




  • http://random.net.ua/video_test/video1.html (ok)

  • http: //random.net.ua/video_test/video2.html (ok)

  • http://random.net.ua/ video_test / video1-mediaelement.html (ok)

  • http://random.net.ua/video_test/video2-mediaelement。 html (fail)


解决方案

c $ c> $(video)。get(0).currentSrc 或者在控制台中相当于你l看到非mediaelement.js版本正在播放Webm视频,Chrome可以播放得很好,但如果您在mediaelement.js版本中查看同样的内容,则会尝试播放MP4。



然后,如果你看看 $(video)。get(0).error ,你会看到你有一个MediaError。检查一下,你会发现它有代码4。根据规范,这是MEDIA_ERR_SRC_NOT_SUPPORTED。



现在,尝试 $(video)。get(0).canPlayType(video / ) - 它返回也许



现在猜测,但也许Chrome报告可能,因为它可以播放一些MP4配置文件,但不能播放其他配置文件。无论原因如何,我个人更喜欢Mediaelement.js将可能视为否,然后继续开展工作,如果没有其他源类型可以在本机播放,则启动Flash后备。很容易修补它来做到这一点。我已经完成了我刚刚完成的一个分支 - 查看 https ://github.com/tremby/mediaelement/tree/maybe-to-no



希望有所帮助。让我知道它是否适合你 - 我希望它会放弃MP4,并尝试WebM,而不是你的情况。在我自己的项目中(调试让我想到了这个问题),我只有 一个MP4文件,并且Flash后备快乐地取代了它。


I'm using the latest mediaelement.js on my website to play html5 video. There is something strange in Google Chrome. He plays one video, but doesn't want to play the other video in mp4 format and doesn't fallback to webm. Both videos were converted with ffmpeg with this params:

ffmpeg -i input.mov -acodec libfaac -ab 96k -vcodec libx264 -vpre slower -vpre main -level 21 -refs 2 -b 345k -bt 345k -threads 0 -s 640x360 output.mp4

Besides, the first video plays normally without using mediaelement.js library in mp4 format and the second one turns into webm format.

Sample pages from http://random.net.ua/video_test/:

  • http://random.net.ua/video_test/video1.html (ok)
  • http://random.net.ua/video_test/video2.html (ok)
  • http://random.net.ua/video_test/video1-mediaelement.html (ok)
  • http://random.net.ua/video_test/video2-mediaelement.html (fail)

解决方案

If you try doing $("video").get(0).currentSrc or equivalent in a console you'll see that the non-mediaelement.js version is playing the Webm video, which Chrome can play just fine, but if you look at the same thing in the mediaelement.js version it's trying to play the MP4.

Then, if you have a look at $("video").get(0).error you'll see you have a MediaError. Inspect that and you see it has "code 4". According to the spec, that is MEDIA_ERR_SRC_NOT_SUPPORTED.

Now, try $("video").get(0).canPlayType("video/mp4") -- it returns "maybe".

This is guesswork now, but perhaps Chrome reports "maybe" because it can play some profiles of MP4 but not others. No matter the reasons, I'd personally prefer Mediaelement.js to treat "maybe" as "no" and go ahead and fire up the Flash fallback if none of the other source types are playable natively. It's easy enough to patch it to do so. I've done exactly that on a fork I just made -- have a look at https://github.com/tremby/mediaelement/tree/maybe-to-no

Hope that helps. Let me know if it works for you -- I'm hoping it'll give up on the MP4 and try the Webm instead in your case. In my own project (debugging which brought me to this question) I have only an MP4 file, and the Flash fallback is happily taking its place.

这篇关于Google Chrome浏览器不想使用mediaelement.js播放mp4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆