java mp3转g722_wav文件转成g722, g729编码的文件

语音系统中经常需要各种编码的音频原始文件(raw file),使用Asterisk 这个著名的IP-PBX软件附带的转码功能就可以实现。

它根据文件的后缀来确定编码格式。

如果asterisk已经在运行,使用asterisk -r 可以进入asterisk的命令行。

"file convert "命令的使用方法:

dev12*CLI> file convert

Usage: file convert

Convert from file_in to file_out. If an absolute path

is not given, the default Asterisk sounds directory

will be used.

Example:

file convert tt-weasels.gsm tt-weasels.ulaw

如果是在脚本里面运行,可以使用rasterisk工具,例如:

rasterisk -x "file convert /tmp/file_in.alaw /tmp/file_out.ulaw"

批量转换的例子:

To ilbc

for a in *.wav; do rasterisk -x "file convert /var/lib/asterisk/sounds/custom/$a /var/lib/asterisk/sounds/custom/`echo $a|sed "s/.wav/.ilbc/"`"; done;

To g729

for a in *.wav; do rasterisk -x "file convert /var/lib/asterisk/sounds/custom/$a /var/lib/asterisk/sounds/custom/`echo $a|sed "s/.wav/.g729/"`"; done;

注意:

Asterisk only accepts .wav files with 8kHz sampling rate. 16kHz sampled .wav files are not acceptable. But you CAN convert from sln16 (signed linear 16kHz sampling rate, 16bit resolution) to g.722.

The trick then is getting your audio file to be an sln16 file in the first place.

This is simply a raw PCM file, as opposed to .wav. In Cool Edit Pro (I guess you can do the same with Audacity but haven't tried myself) simply save your 16kHz sample rate file as "PCM Raw Data" instead of .wav, which gives it the extension .pcm. You can then just change the file extension from pcm to sln16 before copying the file into Asterisk (with WinSCP or whatever). You then have your own wideband custom promt。

另外一个工具是sox, 它可以转换采样率,保存为不同的格式。

参考:

http://www.voip-info.org/wiki/view/Convert+WAV+audio+files+for+use+in+Asterisk

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值