How to encode WAV to play with SIPp
Asked Answered
M

3

7

By looking into another SIPp related question I learned that it is now possible to play WAV files using the rtp_stream action.

I've tried several different WAV files with no success. All I get is some noise instead of the expected sound.

In one comment in the mentioned question there is a simple instruction to convert a WAV file to a compatible format but it didn't work as well.

I've also tried to use sox to convert this file with no success.

Can anyone instruct me on how to generate a valid WAV file to be used with SIPp?

This is my recv 200 OK command which includes the play audio action:

<recv response="200" rtd="true">
  <action>
    <exec rtp_stream="sorry_dave.wav,-1" />
  </action>
</recv>
Michelle answered 5/9, 2016 at 14:2 Comment(0)
M
2

I was looking for different WAV file encodings and found a lot of them on Wikipedia.

I've found one file (8,000 Hz µ-Law) that works correctly with the rtp_stream="8kulaw.wav,-1,0" exec parameter.

This is the file information:

ubuntu@mylinux:~/$ file 8kulaw.wav
8kulaw.wav: RIFF (little-endian) data, WAVE audio, ITU G.711 mu-law, mono 8000 Hz

I've tried to encode this file to the exact same configuration using this Sox command but it did NOT worked:

sox -r 8000 -e u-law sorry_dave.wav sorry_dave4.wav
Michelle answered 8/9, 2016 at 13:8 Comment(1)
Just following up with a comment because I was actually dealing with the same issue. In my case I did not preform full investigation how to do this with the sox or other win/linux tools... but i found out that using online convertor at g711.org works just fine with sipp (3.5 version used). Hope it helps someone.Coelostat
A
6

You can use Audacity to encode wav for sipp : Select in the bottom bar 8000Hz for the project and export the audio as 'Another compressed format' : click 'Options' and select 'WAV (Microsoft)' Header and 'A-Law' Encoding (for PCMA) or 'U-Law' (for PCMU).

You should also verify your scenario file : SDP message must have PCMA or PCMU audio and use "rtpstream_audio_port" like this (for PCMA) :

  m=audio [rtpstream_audio_port] RTP/AVP 8
  a=rtpmap:8 PCMA/8000
Anus answered 8/11, 2016 at 14:31 Comment(0)
M
2

I was looking for different WAV file encodings and found a lot of them on Wikipedia.

I've found one file (8,000 Hz µ-Law) that works correctly with the rtp_stream="8kulaw.wav,-1,0" exec parameter.

This is the file information:

ubuntu@mylinux:~/$ file 8kulaw.wav
8kulaw.wav: RIFF (little-endian) data, WAVE audio, ITU G.711 mu-law, mono 8000 Hz

I've tried to encode this file to the exact same configuration using this Sox command but it did NOT worked:

sox -r 8000 -e u-law sorry_dave.wav sorry_dave4.wav
Michelle answered 8/9, 2016 at 13:8 Comment(1)
Just following up with a comment because I was actually dealing with the same issue. In my case I did not preform full investigation how to do this with the sox or other win/linux tools... but i found out that using online convertor at g711.org works just fine with sipp (3.5 version used). Hope it helps someone.Coelostat
N
0

Sorry - It's a bit vague now as it's been so long since I did this. To my best recollection u-law encoding didn't work in sipp so I encoded the file as a-law using this script I built. I noted there were some nuances to the conversion using sox. In my opinion you either have a mismatched SDP, or are incorrectly encoding the file, make sure you only use one channel. Try the methods and code I posted below.

The file header should read

File Size: 54.7k Bit Rate: 64.1k Encoding: A-law
Channels: 1 @ 13-bit
Samplerate: 8000Hz
Replaygain: off
Duration: 00:00:06.83

or

File Size: 54.7k Bit Rate: 64.1k Encoding: u-law
Channels: 1 @ 14-bit
Samplerate: 8000Hz
Replaygain: off
Duration: 00:00:06.83

./wav_to_gsm.sh sorry_dave.wav sorry_dave_alaw.wav sox alaw

#!/bin/bash

if [ -z "$4" ];then
   echo "usage: $0 [input.wav] [output.gsm] [sox|gst] [alaw|ulaw]"
   exit
fi

  IN=$1
 OUT=$2
TOOL=$3
 ENC=$4

function conv1()
{
   if [ $ENC == "alaw" ];then
      sox $IN -r 8000 -c 1 -e a-law $OUT resample -ql
   else
      sox $IN -r 8000 -c 1 -e u-law $OUT resample -ql  #default
   fi

   #notes:
   #the output file extension (wav or gsm) will change how sox performs the encoding
   #use .wav for sipp RTP
      Encoding: u-law                    Encoding: A-law
      Channels: 1 @ 14-bit               Channels: 1 @ 13-bit
   #use .gsm for asterisk music on hold
      Encoding: GSM
      Channels: 1 @ 16-bit

}

function conv2()
{
   if [ $ENC == "alaw" ];then
      gst-launch  filesrc location=$IN \
      ! wavparse \
      ! audioconvert \
      ! audioresample \
      ! alawenc \
      ! audio/x-alaw, rate=8000, channels=1 \
      ! wavenc \
      ! filesink location=$OUT
   else
      gst-launch  filesrc location=$IN \
      ! wavparse \
      ! audioconvert \
      ! audioresample \
      ! mulawenc \
      ! audio/x-mulaw, rate=8000, channels=1 \
      ! wavenc \
      ! filesink location=$OUT
   fi

   # notes: 
   # file output extension of wav and gsm are interchangeable in the converted format
}

if [ $3 == "gst" ];then
   conv2
else
   conv1
fi
Northey answered 9/9, 2016 at 1:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.