简体   繁体   English

如何使用 JavaScript 在浏览器中检测 WebRTC 支持的视频和音频编解码器?

[英]How can I detect WebRTC supported video and audio codecs in the browser using JavaScript?

Is there a way to check what WebRTC audio and video codecs are supported by the browser?有没有办法检查浏览器支持哪些 WebRTC 音频和视频编解码器?

I have searched around but I can't seem to find a solution.我已经四处寻找,但似乎找不到解决方案。

UPDATE更新

To be more precise , I want to be able to get a list of browser-supported audio and video codecs automatically.更准确地说,我希望能够自动获取浏览器支持的音频和视频编解码器列表。

Something like the pseudo-code below:类似于下面的伪代码:

const supportedAudioCodecs = getBrowserAudioCodecs()
// supportedAudioCodecs => { 'mp3', ... }

const supportedVideoCodecs = getBrowserVideoCodecs()
// supportedVideoCodecs => { 'mp4', ... }

I don't want to have to check if a specific codec exists.我不想检查是否存在特定的编解码器。 I just want to be able to get the supported ones.我只是希望能够获得支持的那些。 Since these things change, I always want to have updated supported codecs from the browser in some way.由于这些事情发生了变化,我总是希望以某种方式从浏览器更新支持的编解码器。

I hope this is clearer.我希望这更清楚。

Not really an out of the box answer, but I think this link is quite usefull : codec capabilities不是一个开箱即用的答案,但我认为这个链接非常有用: 编解码器功能

There is a 10 mins video, explaining the code used to find the codecs supported and some good comments.有一个 10 分钟的视频,解释了用于查找支持的编解码器的代码和一些好评。 You can also find there the fiddle link for the code they are using.您还可以在那里找到他们正在使用的代码的小提琴链接。

The code generate a list of all codecs supported on the browser on send and receive end, not the same at my surprise.该代码在发送和接收端生成浏览器支持的所有编解码器的列表,令我惊讶的是不一样。 I am very new to all of this ^^我对这一切都很陌生^^

In the video/fiddle they are mainly talking about video codec capabilities but it is really easy to adapt this for audio codec too You can see in the script.js file of this link在视频/小提琴中,他们主要讨论视频编解码器功能,但也很容易将其用于音频编解码器您可以在此链接的 script.js 文件中看到

I tested it on different browser / hardware it seems coherent.我在不同的浏览器/硬件上对其进行了测试,它似乎是连贯的。

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 webRTC:如何检测Stream中的音频/视频存在? - webRTC: How to detect audio/video presence in Stream? 如何在webrtc sdp中删除视频编解码器? - How to remove video codecs in webrtc sdp? 使用SIPML5和WEBRTC开发浏览器到浏览器的音频/视频通话 - developing browser to browser audio/video calling using SIPML5 & WEBRTC 如何使用播放器JavaScript检测到断开的视频链接? - How can I detect a broken video link using player JavaScript? 如何使用Javascript检测浏览器是否为Safari 5+? - How can I detect if a browser is Safari 5+ using Javascript? 如何在使用JavaScript的浏览器中检测Flash Player是否已禁用? - How can I detect if Flash Player is disabled in a browser using JavaScript? 如何检测浏览器是否可移动,并使用javascript“ if else”以不同大小显示视频? - How can I detect whether or not a browser is mobile and display a video at different sizes with javascript “if else”? 如何在JavaScript中检测浏览器? - How can I detect the browser in JavaScript? 如何使用PHP或JavaScript检测浏览器? - How can I detect the browser with PHP or JavaScript? 如果 URL 包含浏览器(客户端)上的视频(但不是音频)或音频(但不是视频),如何使用 javascript 检查? - How to check using javascript if URL contains video (but not audio) or audio (but not video) on browser (client side)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM