Firefox MediaSourceExtension上的mp3支持 [英] mp3 support on Firefox MediaSourceExtension

查看:216
本文介绍了Firefox MediaSourceExtension上的mp3支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究在没有插件的情况下在浏览器中实现自适应和渐进音频流的方法. MSE是我一直在等待的HTML5 API,可在FF 42中使用,但是似乎不存在Firefox中的音频格式支持吗?... 使用MSE API时,mp3音频无法正常工作.

这是一个代码段:

var mediaSource = new window.MediaSource();
var audioSourceBuffer;

mediaSource.addEventListener('sourceopen', function (e) {
    try {
        var mimeType = "audio/mpeg";
        audioSourceBuffer = mediaSource.addSourceBuffer(mimeType);
    } catch (e) {
        log('Exception calling addSourceBuffer', e);
        return;
    }
}

调用addSourceBuffer时收到NotSupportedError异常.

Firefox不支持mp3吗?从MDN支持的格式列表中( https://developer.mozilla.org/zh-CN/docs/Web/HTML/Supported_media_formats ),这意味着如果操作系统支持mp3,则应该存在该支持-而我正在测试的OS(OSX)确实支持该支持.

任何帮助表示赞赏!

解决方案

好,所以我能够在从事Media Source Extension的Mozilla工程师的帮助下弄清楚.

关于MSE(媒体源扩展)的第一件事要注意的是,它不一定支持浏览器的音频元素支持的所有媒体格式.为了说明这一点,尽管Firefox在直接输入到浏览器或直接输入到音频元素时将播放mp3文件,但是如果将其输入到媒体源缓冲区中,它会播放同一mp3文件.

现在,Firefox的MSE实施实际上支持哪种媒体格式?答案是,从Firefox 42开始,默认情况下仅支持fMP4(分段MP4).还支持webm,但默认情况下不支持,您的用户将必须通过Firefox的about:config页面手动将其打开.创建新缓冲区时用于馈送媒体源对象的fMP4 mimeType是:audio/mp4; codecs ="mp4a.40.2"

如果您想知道fMP4是什么,它是MPEG-4标准的一部分,更具体地说是第12部分的标准:使用非多路复用音频/视频的ISO基本媒体文件格式(ISOBMFF) ".如果您对更多详细信息感兴趣,请查找它.

根据我的经验,所有主流浏览器和操作系统都支持fMP4-这使fMP4成为自适应和渐进式流传输的理想格式.

HTH!

I'm looking into implementing adaptive and progressive audio streaming in the browser, with no plugins. MSE is the HTML5 API I was waiting for, available in FF 42, but it seems that the audio format support in Firefox is not there?... mp3 audio is not working when using the MSE APIs.

Here's a code snippet:

var mediaSource = new window.MediaSource();
var audioSourceBuffer;

mediaSource.addEventListener('sourceopen', function (e) {
    try {
        var mimeType = "audio/mpeg";
        audioSourceBuffer = mediaSource.addSourceBuffer(mimeType);
    } catch (e) {
        log('Exception calling addSourceBuffer', e);
        return;
    }
}

I get a NotSupportedError exception when calling addSourceBuffer.

Doesn't Firefox support mp3? from MDN list of supported formats (https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats) it implies that mp3 support should be there if the OS supports it - and the OS I am testing on (OSX) does support it.

Any help appreciated!

解决方案

OK, so I was able to figure it out with the kind help of Mozilla engineers working on Media Source Extension.

The first key thing to note on MSE (Media Source Extension) is that it does not necessarily support all media formats supported by the browser's Audio Element. To illustrate this, although Firefox will play mp3 file when fed directly to the browser or directly to an Audio element, it will not play the same mp3 file if you feed it into a media source buffer.

Now, which media format are actually supported by Firefox' MSE implementation? the answer is that as of Firefox 42 only fMP4 (Fragmented MP4) is supported by default. webm is also supported, but not by default and your users will have to turn it on manually through Firefox' about:config page. The fMP4 mimeType to feed the Media Source object when creating a new buffer is: audio/mp4; codecs="mp4a.40.2"

And if you're wondering what the heck is fMP4, it is a standard which is part of the MPEG-4 standard, more specifically part 12: "ISO Base Media File Format (ISOBMFF) using non-multiplexed audio/video". Look it up if you're interested in more details.

From my experience fMP4 is supported across all major browsers and OS - which makes fMP4 a good format candidate for adaptive and progressive streaming.

HTH!

这篇关于Firefox MediaSourceExtension上的mp3支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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