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/
本文介绍了如何利用GStreamer管道进行PCM音频的编码与解码操作。具体包括将WAV文件转换为PCM格式、批量转换多个WAV文件、将PCM转换回WAV格式、播放PCM文件以及使用xxd工具创建PCM数据的C数组。

910

被折叠的 条评论
为什么被折叠?



