11-4_音频转码部署

音频转码部署

1.G711编码部署

参考链接:escrichov/G711: PCM to G711 Fast Conversions

获取开源仓库源码:

git clone https://github.com/escrichov/G711.git

如果获取不了,请访问资料网盘中的01_视频教程/02_配套资源目录中获取

进入工程目录

cd G711

编译工程

make

G711编码音频文件

./example example_files/alaw.raw alaw_pcm alaw_to_pcm.audio
./example example_files/ulaw.raw ulaw_pcm ulaw_to_pcm.audio
./example example_files/pcm.raw pcm_alaw pcm_to_alaw.audio
./example example_files/pcm.raw pcm_ulaw pcm_to_ulaw.audio
./example example_files/input.pcm pcm_alaw input_pcm_to_alaw.audio 

使用ffmpeg播放编码后的码流

对于alaw/ulaw编码后的码流:

ffplay -ar 44100 -ac 2 -f s16le -i ulaw_to_pcm.audio

对于pcm编码后的码流:

ffplay -f alaw -ar 44100 -ac 2 -i pcm_to_alaw.audio 
ffplay -f mulaw -ar 44100 -ac 2 -i pcm_to_ulaw.audio

注意:上面的G711源码仅供学习参考!!