# TypeError: duplicated codec.preferredPayloadType

**URL:** <https://mediasoup.discourse.group/t/typeerror-duplicated-codec-preferredpayloadtype/3391>\
**Category:** mediasoup libraries\
**Created:** [October 7, 2021, 11:41am UTC](https://mediasoup.discourse.group/t/typeerror-duplicated-codec-preferredpayloadtype/3391 "2021-10-07T11:41:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![j1elo](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/j1elo/32/1010_2.png) [@j1elo](https://mediasoup.discourse.group/u/j1elo)\
**Post date:** [October 7, 2021, 12:17pm UTC](https://mediasoup.discourse.group/t/typeerror-duplicated-codec-preferredpayloadtype/3391/4 "2021-10-07T12:17:00Z")

</div>

**Confirmed** The error `duplicated codec.preferredPayloadType` was being caused by too many elements in the array returned by `getSupportedRtpCapabilities()`. Thanks for that tip!

This works; it just removes some of the most repeated codecs which are not that interesting for WebRTC usage with current web browsers:

```auto
worker.createRouter({
  mediaCodecs: Mediasoup.getSupportedRtpCapabilities()
    .codecs?.filter(
      (c) =>
        c.mimeType !== "audio/SILK" &&
        c.mimeType !== "audio/CN" &&
        c.mimeType !== "audio/telephone-event"
    )
    .map((c) => {
      delete c.preferredPayloadType;
      return c;
    }),
});

```

---

_[View the full topic](https://mediasoup.discourse.group/t/typeerror-duplicated-codec-preferredpayloadtype/3391)._
