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

1.7k views Asked by At

Is there a way to check what WebRTC audio and video codecs are supported by the browser?

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.

1

There are 1 answers

1
Loulou BadWeed On

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. 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

I tested it on different browser / hardware it seems coherent.

Hope it helps