Html 使用 HTML5 视频在 Firefox 中播放 MP4 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10488768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Playing MP4 files in Firefox using HTML5 video
提问by TJ Sherrill
I have searched around quite a bit but have not solved my problem.
我已经搜索了很多,但没有解决我的问题。
I have a video
tag running as follows:
我有一个video
标签运行如下:
<video
class="ne"
src="{{ page | video_url }}"
muted="true"
volume="0"
controls
width="720"
height="480"
poster="{{ page | video_poster_image_url }}"
type="video/mp4">
</video>
I am using Jekyll for the URLs. They work fine.
我使用 Jekyll 作为 URL。他们工作得很好。
The site is live at switzerlandllc.com. Click any video in FF and it shows an image and an X. Chrome and other browsers work fine.
该网站位于switzerlandllc.com。单击 FF 中的任何视频,它会显示一个图像和一个 X。Chrome 和其他浏览器工作正常。
If you grab the source of a video and load it in a new tab it plays fine. At least it does for me.
如果您获取视频源并将其加载到新选项卡中,则它可以正常播放。至少对我来说是这样。
I have added:
我已经添加了:
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
to my htaccess
file. I suspect that I don't need the .ogv
or .webm
.
到我的htaccess
文件。我怀疑我不需要.ogv
or .webm
。
I don't understand why loading the video URL will play the videos fine but loading the video into a video tag fails.
我不明白为什么加载视频 URL 可以正常播放视频,但将视频加载到视频标签中失败。
Any ideas?
有任何想法吗?
回答by Josh Mein
This is caused by the limited support for the MP4 format within the video tag in Firefox. Support was not added until Firefox 21, and it is still limited to Windows 7 and above. The main reason for the limited support revolves around the royalty fee attached to the mp4 format.
这是由于 Firefox 的视频标签中对 MP4 格式的支持有限造成的。直到 Firefox 21 才添加支持,并且仍然仅限于 Windows 7 及更高版本。支持有限的主要原因在于 mp4 格式附带的版税。
Check out Supported media formatsand Media formats supported by the audio and video elementsdirectly from the Mozilla crew or the following blog post for more information:
直接从 Mozilla 工作人员或以下博客文章中查看支持的媒体格式和音频和视频元素支持的媒体格式以获取更多信息:
http://pauljacobson.org/2010/01/22/2010122firefox-and-its-limited-html-5-video-support-html/
http://pauljacobson.org/2010/01/22/2010122firefox-and-its-limited-html-5-video-support-html/
回答by wes
I can confirm that mp4 just will not work in the video tag. No matter how much you try to mess with the type tag and the codec and the mime types from the server.
我可以确认 mp4 在视频标签中不起作用。无论您如何尝试弄乱类型标记和编解码器以及来自服务器的 mime 类型。
Crazy, because for the same exact video, on the same test page, the old embed tag for an mp4 works just fine in firefox. I spent all yesterday messing with this. Firefox is like IE all of a sudden, hours and hours of time, not billable. Yay.
太疯狂了,因为对于完全相同的视频,在同一个测试页面上,旧的 mp4 嵌入标签在 Firefox 中工作得很好。我昨天花了所有时间来搞这个。火狐浏览器一下子就跟IE一样,一小时又一小时,不收费。好极了。
Speaking of IE, it fails FAR MORE gracefully on this. When it can't match up the format it falls to the content between the tags, so it is possible to just put video around object around embed and everything works great. Firefox, nope, despite failing, it puts up the poster image (greyed out so that isn't even useful as a fallback) with an error message smack in the middle. So now the options are put in browser recognition code (meaning we've gained nothing on embedding videos in the last ten years) or ditch html5.
说到 IE,它在这方面失败得更优雅。当它无法匹配格式时,它会落在标签之间的内容上,因此可以将视频放在嵌入对象周围,一切都很好。Firefox,不,尽管失败了,它还是张贴了海报图像(变灰,因此作为后备甚至没有用),中间有一条错误消息。所以现在选项被放在浏览器识别代码中(意味着我们在过去十年中在嵌入视频方面一无所获)或抛弃 html5。