[英]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.