Html 如何在 Firefox 中播放 MP4 视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40760864/
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
How to play MP4 video in firefox
提问by baig772
I have a dynamic video path coming from database. Video can be uploaded in any format. When I load the video in Firefox, I see the following errors
我有一个来自数据库的动态视频路径。视频可以以任何格式上传。当我在 Firefox 中加载视频时,我看到以下错误
Specified “type” attribute of “video/mp4” is not supported. Load of media resource path_to_video.mp4 failed.
不支持“video/mp4”的指定“type”属性。媒体资源 path_to_video.mp4 加载失败。
I am loading the video in my html like
我正在我的 html 中加载视频
<p>
<video class="responsive-video" id="trailer">
<source src="<?php echo $biovideo?>" type="video/mp4">
</video>
</p>
Is there any way to play the mp4 videos in Firefox as I am not sure what extension the video will have
有什么方法可以在 Firefox 中播放 mp4 视频,因为我不确定视频的扩展名是什么
回答by Mick
Update - Feb 2019
更新 - 2019 年 2 月
Firefox no longer uses GStreamer and instead interfaces directly with ffmpeg. Hence the flag mentioned below will no longer appear in current version of Firefox.
Firefox 不再使用 GStreamer,而是直接与 ffmpeg 接口。因此,下面提到的标志将不再出现在当前版本的 Firefox 中。
There is now a flag media.ffmpeg.enabled which again can be set to true:
现在有一个标志 media.ffmpeg.enabled 可以再次设置为 true:
- go to Firefox about:config
- search for the 'media.ffmpeg.enabled' flag
- set it to true
- 转到 Firefox about:config
- 搜索“media.ffmpeg.enabled”标志
- 将其设置为 true
In practice this is not necessary on many platforms - the latest official Firefox online notes say:
在实践中,这在许多平台上是不必要的——最新的官方 Firefox 在线注释说:
Patented media MP3, AAC, and H.264/MPEG-4 AVC are patented audio/video compression formats. They can be viewed in Firefox using built-in OS libraries (so neither Mozilla nor you need to pay a fee) if embedded in the MP4 container format (.mp4, .m4a, .m4p, .m4b, .m4r, .m4v file types).
获得专利的媒体 MP3、AAC 和 H.264/MPEG-4 AVC 是获得专利的音频/视频压缩格式。如果嵌入 MP4 容器格式(.mp4、.m4a、.m4p、.m4b、.m4r、.m4v 文件),则可以使用内置操作系统库在 Firefox 中查看它们(因此 Mozilla 和您都不需要支付费用)类型)。
To verify, a test as at February 2019:
为了验证,截至 2019 年 2 月的测试:
- With a clean install of Ubuntu 18.04, Firefox could not play a test mp4 stream. It can play video using other container standards, those with the following file extensions: webm and ogg
- In the terminal ran 'sudo apt-get install ubuntu-restricted-extras' and accepted all licenses etc
- With no other changes, i.e. no flag setting etc, Firefox can now play the test mp4 stream
- 全新安装 Ubuntu 18.04 后,Firefox 无法播放测试 mp4 流。它可以使用其他容器标准播放视频,这些标准具有以下文件扩展名:webm 和 ogg
- 在终端中运行“sudo apt-get install ubuntu-restricted-extras”并接受所有许可证等
- 没有其他变化,即没有标志设置等,Firefox 现在可以播放测试 mp4 流
Original answer - for older versions of Firefox
原始答案 - 适用于旧版本的 Firefox
As noted in the comments Ubuntu/firefox does not support mp4 natively - this is due to licensing issues. The Mozilla documentation is a little confusing (IMHO) so the table at the bottom is probably the best place to look.
正如评论中所指出的,Ubuntu/firefox 本身不支持 mp4 - 这是由于许可问题。Mozilla 文档有点混乱(恕我直言),因此底部的表格可能是最好的查看位置。
However you can add support fairly easily by installing Ubuntu extras:
但是,您可以通过安装 Ubuntu extras 来轻松添加支持:
sudo apt-get install ubuntu-restricted-extras
sudo apt-get install ubuntu-restricted-extras
and then enabling gstreamer:
然后启用 gstreamer:
- go to Firefox about:config
- search for the 'media.gstreamer.enabled' flag
- set it to enabled
- 转到 Firefox about:config
- 搜索“media.gstreamer.enabled”标志
- 将其设置为启用
This should allow you play the video.
这应该允许您播放视频。