Read and write raw PCM using GStreamer

Embedded developers have a frequent need to encode or decode PCM audio. In this post I show some GStreamer pipelines that can help with that task.

Convert WAV to PCM

1
gst-launch filesrc location= file .wav ! wavparse ! audioresample ! audioconvert ! audio /x-raw-int , rate=8000, channels=1, endianness=4321, width=16, depth=16, signed= true ! filesink location= file .pcm

For bulk conversion

1
ls *.wav | xargs -i -n 1 gst-launch filesrc location= '{}' ! wavparse ! audioresample ! audioconvert ! audio /x-raw-int , rate=8000, channels=1, endianness=4321, width=16, depth=16, signed= true ! filesink location= '{}' .pcm

Convert PCM to WAV

1
gst-launch filesrc location= file .pcm ! audio /x-raw-int , rate=8000, channels=1, endianness=4321, width=16, depth=16, signed= true ! audioconvert ! audio /x-raw-int , rate=8000, channels=1, endianness=1234, width=16, depth=16, signed= true ! wavenc ! filesink location= file .wav

Play PCM

1
gst-launch filesrc location= file .pcm ! audio /x-raw-int , rate=8000, channels=1, endianness=4321, width=16, depth=16, signed= true ! pulsesink

Use xxd to create C array of PCM data

1
xxd -i file .pcm > voice.c


转自:https://delog.wordpress.com/2011/10/04/read-and-write-raw-pcm-using-gstreamer/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值