# ARI ExternalMedia and slin format with 8 kHz 16 bit

**URL:** <https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605>\
**Category:** Asterisk APIs\
**Created:** [July 1, 2023, 3:05pm UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605 "2023-07-01T15:05:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ari\_segfault](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ari_segfault/32/6157_2.png) [@ari\_segfault](https://community.asterisk.org/u/ari_segfault)\
**Post date:** [July 1, 2023, 3:05pm UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605/1 "2023-07-01T15:05:53Z")

</div>

Using ARI queries, I create a bridge with two channels for Alice and Bob. After that, I create a bridge for the Snoop channel and the ExternalMedia channel. Below is a brief drawing  
 ![image](https://global.discourse-cdn.com/asterisk/original/2X/6/6d9712539847bf5dec71b4df9884194e121d6a65.png)

In my application, I receive an RTP stream and save the file. And everything works well if i create ExternalMedia channel with such POST parameters, where there is “ **slin16** ”:

```auto
{
"channelId": "EM123",
"app": "TEST_APP",
"external_host": "127.0.0.1:1234",
"encapsulation": "rtp",
"transport": "udp",
"connection_type": "client",
"format": "slin16",
"direction": "both"
}

```

I can save such a stream to a wav file of 16 kHz and 16 bit

But is it possible to transmit a stream of 8 kHz and 16 bit?  
If I specify “ **slin8** ” when creating a channel, I get the error below::

> Provided format (slin8) was not found

If I specify “ **slin** ” when creating a channel, then I will get a u-law stream 8 kHz 8 bit, but i need PCM 8 kHz 16 bit.  
Of course there is a quick way to convert 16 kHz 16 bit to 8 kHz 16 bit, but I wonder why instead of PCM I get **u-law**

Below is more detailed information about the channel inside asterisk if I use “ **slin** ”:  
`asterisk -x 'core show channel UnicastRTP/127.0.0.1:1234-0x7f48b401b760`

```auto
 -- General --
           Name: UnicastRTP/127.0.0.1:1234-0x7f48b401b760
           Type: UnicastRTP
       UniqueID: emedia_123
       LinkedID: snoop_123
      Caller ID: (N/A)
 Caller ID Name: (N/A)
Connected Line ID: (N/A)
Connected Line ID Name: (N/A)
Eff. Connected Line ID: (N/A)
Eff. Connected Line ID Name: (N/A)
    DNID Digits: (N/A)
       Language: en
          State: Up (6)
  NativeFormats: (ulaw)
    WriteFormat: slin
     ReadFormat: slin
 WriteTranscode: Yes (slin@8000)->(ulaw@8000)
  ReadTranscode: Yes (ulaw@8000)->(slin@8000)
 Time to Hangup: 0
   Elapsed Time: 0h0m8s
      Bridge ID: bridge_123
 -- PBX --
        Context: default
      Extension: s
       Priority: 1
     Call Group: 0
   Pickup Group: 0
    Application: Stasis
           Data: callpy
 Call Identifer: (None)
      Variables:
BRIDGEPEER=Snoop/123
STASISSTATUS=
UNICASTRTP_LOCAL_PORT=10660
UNICASTRTP_LOCAL_ADDRESS=127.0.0.1
 -- Streams --
Name: audio-0
    Type: audio
    State: sendrecv
    Group: -1
    Formats: (ulaw)
    Metadata:

```

And if I use “ **slin16** ”:

```auto
 -- General --
           Name: UnicastRTP/127.0.0.1:1234-0x7f494c02f4e0
           Type: UnicastRTP
       UniqueID: emedia_123
       LinkedID: snoop_123
      Caller ID: (N/A)
 Caller ID Name: (N/A)
Connected Line ID: (N/A)
Connected Line ID Name: (N/A)
Eff. Connected Line ID: (N/A)
Eff. Connected Line ID Name: (N/A)
    DNID Digits: (N/A)
       Language: en
          State: Up (6)
  NativeFormats: (slin16)
    WriteFormat: slin16
     ReadFormat: slin16
 WriteTranscode: No 
  ReadTranscode: No 
 Time to Hangup: 0
   Elapsed Time: 0h0m7s
      Bridge ID: bridge_snoop_123
 -- PBX --
        Context: default
      Extension: s
       Priority: 1
     Call Group: 0
   Pickup Group: 0
    Application: Stasis
           Data: callpy
 Call Identifer: (None)
      Variables:
BRIDGEPEER=Snoop/123-00000010
STASISSTATUS=
UNICASTRTP_LOCAL_PORT=10614
UNICASTRTP_LOCAL_ADDRESS=127.0.0.1
 -- Streams --
Name: audio-0
    Type: audio
    State: sendrecv
    Group: -1
    Formats: (slin16)
    Metadata:

```

---

<div class="post-metadata">

**Author:** ![ldo](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@ldo](https://community.asterisk.org/u/ldo)\
**Post date:** [July 9, 2023, 3:57am UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605/2 "2023-07-09T03:57:47Z")

</div>

It could be that PCM 8-bit is not considered worth supporting. A-law and µ-law give you improved S-N/dynamic-range anyway, that PCM can only match by going to, I dunno, 10 bits or something.

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [July 9, 2023, 11:24am UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605/3 "2023-07-09T11:24:23Z")

</div>

The figure after the slin is the sample rate, not the bit width. They are all 16 bits. There isn’t an slin8 because it is the most simple case and is called slin.

---

<div class="post-metadata">

**Author:** ![ari\_segfault](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ari_segfault/32/6157_2.png) [@ari\_segfault](https://community.asterisk.org/u/ari_segfault)\
**Post date:** [July 9, 2023, 12:22pm UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605/4 "2023-07-09T12:22:09Z")

</div>

I need a sampling rate of 8 kHz **PCM** 16 bits. If i use **slin** , then the frequency is 8 kHz 8 bit **u-law**.  
I don’t need **ulaw** , when I need it I can specify **ulaw** in the request

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [July 9, 2023, 12:40pm UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605/5 "2023-07-09T12:40:23Z")

</div>

slin stands for signed linear. µ-Law isn’t linear. If you are getting µ-Law it is either a bug, or it is the best available encoding to your over the wire one.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [August 8, 2023, 12:41pm UTC](https://community.asterisk.org/t/ari-externalmedia-and-slin-format-with-8-khz-16-bit/97605/6 "2023-08-08T12:41:10Z")

</div>

Closed on August 8, 2023, 12:41pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
