通过查看另一个SIPp related question,我了解到现在可以使用rtp_stream
操作播放WAV文件。
我尝试了几种不同的WAV文件但没有成功。我得到的只是一些噪音而不是预期的声音。
在上述问题的一条评论中,有一条简单的指令可以将WAV文件转换为兼容格式,但它不能正常工作。
我还尝试使用sox转换this file但没有成功。
有人可以告诉我如何生成与SIPp一起使用的有效WAV文件吗?
这是我的recv 200 OK
命令,其中包含播放音频操作:
<recv response="200" rtd="true">
<action>
<exec rtp_stream="sorry_dave.wav,-1" />
</action>
</recv>
答案 0 :(得分:5)
您可以使用Audacity为sipp编码wav: 在项目的底部栏中选择8000Hz并将音频导出为另一种压缩格式&#39; :点击&#39;选项&#39;并选择WAV(微软)&#39;标题和&#39; A-Law&#39;编码(对于PCMA)或“U-Law”#39; (对于PCMU)。
您还应该验证您的方案文件:SDP消息必须具有PCMA或PCMU音频并使用&#34; rtpstream_audio_port&#34;像这样(对于PCMA):
m=audio [rtpstream_audio_port] RTP/AVP 8
a=rtpmap:8 PCMA/8000
答案 1 :(得分:1)
我正在寻找不同的WAV文件编码,并在Wikipedia上找到了很多。
我发现one file(8,000 Hz µ-Law
)与rtp_stream="8kulaw.wav,-1,0"
exec参数一起正常工作。
这是文件信息:
ubuntu@mylinux:~/$ file 8kulaw.wav
8kulaw.wav: RIFF (little-endian) data, WAVE audio, ITU G.711 mu-law, mono 8000 Hz
我尝试使用此Sox
命令将this file编码为完全相同的配置,但它没有起作用:
sox -r 8000 -e u-law sorry_dave.wav sorry_dave4.wav
答案 2 :(得分:0)
抱歉 - 由于我这么做了很长时间,所以现在有点模糊了。为了我最好的回忆,u-law编码在sipp中没有用,所以我使用我构建的脚本将文件编码为a-law。我注意到使用sox进行转换有一些细微差别。在我看来,你有一个不匹配的SDP,或者错误地编码文件,请确保你只使用一个频道。试试我在下面发布的方法和代码。
文件标题应为
文件大小:54.7k比特率:64.1k
编码:A-law
频道:1 @ 13位
采样率:8000Hz
重播:关闭
持续时间:00:00:06.83
或
文件大小:54.7k比特率:64.1k
编码:u-law
频道:1 @ 14位
采样率:8000Hz
重播:关闭
持续时间:00:00:06.83
#!/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