简体   繁体   English

使用gstreamer对音频rtp进行重采样和取消负载

[英]Resample and depayload audio rtp using gstreamer

I am developing an application where I am using a wave file from a location at one end of a pipeline and udpsink at the other end of it. 我正在开发一个应用程序,其中我在管道一端使用波形文件 ,而在管道另一端使用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

The Above wave file is having sampling rate = 44100 Hz and single-channel(mono) 上面的波形文件具有采样率= 44100 Hz和单通道(单声道)

On the same PC I am using a c++ program application to catch these packets and depayload to a headerless audio file (say Tornado.raw) 在同一台PC上,我正在使用c++程序应用程序来捕获这些数据包,并将其卸载到无头文件的音频文件中(例如Tornado.raw)

The pipeline I am creating for this is basically 我为此创建的管道基本上是

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

Now This works fine. 现在,这工作正常。 I get the headerless data and when I play it using the Audacity It plays great! 我得到了无头数据,并且当我使用Audacity播放它时,它发挥的很好!

I am trying to resample this audio file while it is in pipeline from 44100 Hz to 8000 Hz 我正在尝试从44100 Hz到8000 Hz的管道中的音频文件重新采样

Simply changing the clock-rate=(int)44100 to clock-rate=(int)8000 is not helping (also absurd logically) I am looking for how to get the headerless file at the pipeline output with 8000 Hz sampling. 只是将clock-rate=(int)44100更改为clock-rate=(int)8000并没有帮助(逻辑上也是荒谬的),我正在寻找如何以8000 Hz采样在流水线输出处获取无头文件。

Also the data that I am getting now is Big-endian, but I want Little-endian as output. 另外,我现在获取的数据是Big-endian,但我希望Little-endian作为输出。 how do I set that in the pipeline? 如何在管道中进行设置?

You might relate this to one of my earlier question . 您可能将此与我先前的问题之一相关

First, you have some weird caps in your pipeline - width and height are for video here. 首先,您的管道中有一些奇怪的上限-宽度和高度用于此处的视频。 They probably will be just ignored.. but still.. not sure on others there as well but meh.. 他们可能会被忽略..但仍然..也不确定其他人,但是..

For the actual question. 对于实际的问题。 Just use audioresample and audioconvert elements of Gstreamer to transfer in your desired format. 只需使用audioresampleaudioconvert了GStreamer元素在你想要的格式进行传输。

Eg 例如

[..] ! rtpL16depay ! audioresample ! audioconvert ! \
audio/x-raw, rate=8000, format=S16LE ! filesink location=Tornado.raw

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM