HTML5 我的 Firefox 不支持视频,但在其他地方可以使用
HTML5 video in not supported on my Firefox but works elsewhere
我在我的项目中使用 HTML5 <video>
标签和 MP4 视频。当我测试它时,它只适用于 Chrome 但不适用于 Firefox 或 IE。当我试用我朋友的笔记本电脑时,只有五分之一的人和我的有同样的问题,对于其他人来说,视频在 Chrome、Firefox 和 IE 中运行良好。我想知道是什么导致了这种行为。在所有计算机上都是 Firefox 46.0.1。这是我的 HTML 代码:
<video id="video1" width="100%" height="auto" controls>
<source src="the-mountain.MP4" type="video/mp4">
</video>
如何解决这个问题?该项目必须至少与 Chrome、Firefox 和 IE > 9 兼容。
您可以使用 caniuse 检查您的视频是否支持 http://caniuse.com/#feat=video
对于子功能,您可以检查
http://caniuse.com/#feat=webm ,
http://caniuse.com/#feat=mpeg4 ,
http://caniuse.com/#feat=ogv ,
http://caniuse.com/#feat=webvtt
对于 MP4,支持的版本来自具有此规范的 FF45
Firefox supports H.264 on Windows 7 and later since version 21.
Firefox supports H.264 on Linux since version 26 if the appropriate
gstreamer plug-ins are installed.
Partial support for older Firefox versions refers to the lack of
support in OS X & some non-Android Linux platforms.
还有来自 FF 文档的一个小建议尝试使用像素作为宽度和高度 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
height
The height of the video's display area, in CSS pixels.
width
The width of the video's display area, in CSS pixels.
问题是 MPEG 不是免费格式。
Microsoft、Apple 和 Google 拥有允许他们在其浏览器中原生支持该格式的许可证。然而,Firefox 是一个开源项目,不支付 MPEG LA 费用。因此,对 MPEG 视频的支持取决于第三方解码器的存在。 (Source)
安装 QuickTime plugin 可能会解决这个问题。
MP4 容器、H.264(视频)和 AAC(音频)中使用的编解码器受专利保护,因此 mozilla 决定不在 Firefox 本身中实现这些编解码器,而是依赖 support from the OS or device hardware. In case of H264, there is also the OpenH264 plugin Firefox 可能会自行安装。
您在评论中提到您正在使用 Windows 10 Pro N,所以 the Windows version that comes without the codecs Firefox 通常会在 Windows 上使用。因此没有播放。 OpenH264 可以让您在 MP4 文件中播放 H.264,但您仍然缺少用于音频的 AAC 解码器。
The Knowledge base article 还链接到一个下载链接,可以让您将 N 版变成 "full" 版,但是,这只会解决您的问题,而不是其他 Windows Firefox 上的 N 版用户。
要支持此类用户,您必须提供 webm 版本(附加 <source>
)。
我在我的项目中使用 HTML5 <video>
标签和 MP4 视频。当我测试它时,它只适用于 Chrome 但不适用于 Firefox 或 IE。当我试用我朋友的笔记本电脑时,只有五分之一的人和我的有同样的问题,对于其他人来说,视频在 Chrome、Firefox 和 IE 中运行良好。我想知道是什么导致了这种行为。在所有计算机上都是 Firefox 46.0.1。这是我的 HTML 代码:
<video id="video1" width="100%" height="auto" controls>
<source src="the-mountain.MP4" type="video/mp4">
</video>
如何解决这个问题?该项目必须至少与 Chrome、Firefox 和 IE > 9 兼容。
您可以使用 caniuse 检查您的视频是否支持 http://caniuse.com/#feat=video 对于子功能,您可以检查
http://caniuse.com/#feat=webm ,
http://caniuse.com/#feat=mpeg4 ,
http://caniuse.com/#feat=ogv ,
http://caniuse.com/#feat=webvtt
对于 MP4,支持的版本来自具有此规范的 FF45
Firefox supports H.264 on Windows 7 and later since version 21. Firefox supports H.264 on Linux since version 26 if the appropriate gstreamer plug-ins are installed.
Partial support for older Firefox versions refers to the lack of support in OS X & some non-Android Linux platforms.
还有来自 FF 文档的一个小建议尝试使用像素作为宽度和高度 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
height
The height of the video's display area, in CSS pixels. width
The width of the video's display area, in CSS pixels.
问题是 MPEG 不是免费格式。
Microsoft、Apple 和 Google 拥有允许他们在其浏览器中原生支持该格式的许可证。然而,Firefox 是一个开源项目,不支付 MPEG LA 费用。因此,对 MPEG 视频的支持取决于第三方解码器的存在。 (Source)
安装 QuickTime plugin 可能会解决这个问题。
MP4 容器、H.264(视频)和 AAC(音频)中使用的编解码器受专利保护,因此 mozilla 决定不在 Firefox 本身中实现这些编解码器,而是依赖 support from the OS or device hardware. In case of H264, there is also the OpenH264 plugin Firefox 可能会自行安装。
您在评论中提到您正在使用 Windows 10 Pro N,所以 the Windows version that comes without the codecs Firefox 通常会在 Windows 上使用。因此没有播放。 OpenH264 可以让您在 MP4 文件中播放 H.264,但您仍然缺少用于音频的 AAC 解码器。
The Knowledge base article 还链接到一个下载链接,可以让您将 N 版变成 "full" 版,但是,这只会解决您的问题,而不是其他 Windows Firefox 上的 N 版用户。
要支持此类用户,您必须提供 webm 版本(附加 <source>
)。