我正在开发一个应用程序,我在其中使用来自管道一端某个位置的wave 文件 和udpsink 在它的另一端。
gst-launch-1.0 filesrc location=/path/to/wave/file/Tornado.wav ! wavparse ! audioconvert ! audio/x-raw,channels=1,depth=16,width=16,rate=44100 ! rtpL16pay ! udpsink host=xxx.xxx.xxx.xxx port=5000
上述波形文件的采样率 = 44100 Hz 和单 channel (单声道)
在同一台 PC 上,我正在使用 c++
程序应用程序捕获这些数据包 并将卸载 到 headless 音频文件(说 Tornado.raw)
我为此创建的管道基本上是
gst-launch-1.0 udpsrc port=5000 ! "application/x-rtp,media=(string)audio, clock-rate=(int)44100, width=16, height=16, encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1, channel-positions=(int)1, payload=(int)96" ! rtpL16depay ! filesink location=Tornado.raw
现在一切正常。我得到了 headless 数据,当我使用 Audacity 播放它时,它播放得很好!
我正在尝试在该音频文件处于从 44100 Hz 到 8000 Hz 的管道时对其进行重新采样
简单地将 clock-rate=(int)44100
更改为 clock-rate=(int)8000
没有帮助(逻辑上也是荒谬的)
我正在寻找如何通过 8000 Hz 采样在管道输出处获取 headless 文件。
此外,我现在获取的数据是 Big-endian,但我想要 Little-endian 作为输出。我如何在管道中设置它?
您可能会将其与 my earlier question 之一相关联.
最佳答案
首先,您的管道中有一些奇怪的上限 - 此处的宽度和高度用于视频。他们可能会被忽略……但仍然……不确定那里的其他人也一样,但是嗯……
对于实际问题。只需使用 Gstreamer 的 audioresample
和 audioconvert
元素以您想要的格式传输。
例如
[..] ! rtpL16depay ! audioresample ! audioconvert ! \
audio/x-raw, rate=8000, format=S16LE ! filesink location=Tornado.raw
关于c++ - 使用 gstreamer 重新采样和卸载音频 rtp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54669358/