使用GStreamer在本地网络上移动音频

时间:2010-04-26 16:52:31

标签: audio-streaming gstreamer

我需要在两台Linux机器之间移动实时音频,这两台机器都运行自定义软件(我的),它建立在Gstreamer之上。 (该软件已经通过单独的基于TCP的协议在机器之间进行了其他通信 - 我提到这一点,如果有可靠的带外数据会对解决方案产生影响)。

音频输入将是发送机器上的麦克风/线路输入,并且正常音频输出将作为目的地上的接收器; alsasrc和alsasink是最有可能的,但是对于测试我一直在使用audiotestsrc而不是真正的麦克风。

GStreamer提供多种方式在网络上传输数据 - RTP,RTSP,GDP支付,UDP和TCP服务器,客户端和套接字等。在音频和视频流媒体网络上也有很多例子 - 但在实践中,它们似乎都不适用于我;目标管道无法协商上限,或者我听到一个数据包,然后管道停止,或者目标管道立即退出,没有可用的数据。

在所有情况下,我都在命令行上测试gst-launch。不需要压缩音频数据 - 原始音频,或简单的WAV,uLaw或aLaw编码都可以;更重要的是低延迟。

3 个答案:

答案 0 :(得分:5)

要调试我会尝试的那种问题:

  1. 运行gst-launch audiotestsrc ! alsasink检查声音是否有效
  2. 使用fakesinkfilesink查看我们是否获得了任何缓冲区
  3. 尝试使用GST_DEBUG查找管道问题,例如使用GST_DEBUG=GST_CAPS:4检查上限或选中使用*:2以获取所有错误/警告
  4. 使用wireshark查看是否发送了数据包
  5. 这些管道对我有用:

    使用RTP:

    gst-launch-0.10 -v 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 ! audioconvert ! alsasink sync=false
    
    gst-launch-0.10 audiotestsrc ! audioconvert ! audio/x-raw-int,channels=1,depth=16,width=16,rate=44100 ! rtpL16pay  ! udpsink host=localhost port=5000
    
    使用TCP

    gst-launch-0.10 tcpserversrc host=localhost port=3000 ! audio/x-raw-int, endianness="(int)1234", signed="(boolean)true", width="(int)16", depth="(int)16", rate="(int)44100", channels="(int)1" ! alsasink
    
    gst-launch-0.10 audiotestsrc ! tcpclientsink host=localhost port=3000
    

答案 1 :(得分:1)

您可以发布一些您尝试过的gst-launch管道吗?这可能有助于理解您遇到问题的原因。通常,RTP / RTSP应该很容易工作。

编辑: 我能想到的情侣项目是 1.将host = localhost更改为host =其他linux机器的实际IP地址 2.将caps =“application / x-rtp,media =(string)audio添加到接收器中的udpsrc元素。

答案 2 :(得分:0)

我的解决方案与tilljoel非常相似,但我使用Microphone(这是你需要的)作为源 - 因此在gstreamer管道中进行了一些调整。

使用TCP从麦克风解码音频:

gst-launch-0.10 tcpserversrc host=localhost port=3000 !  audio/x-raw-int, endianness="(int)1234", signed="(boolean)true", width="(int)16", depth="(int)16", rate="(int)22000", channels="(int)1" ! alsasink

使用TCP从麦克风编码音频:

gst-launch-0.10 pulsesrc ! audio/x-raw-int,rate=22000,channels=1,width=16 ! tcpclientsink host=localhost port=3000

使用RTP从麦克风解码音频:

gst-launch-0.10 -v udpsrc port=5000 ! "application/x-rtp,media=(string)audio, clock-rate=(int)22000, width=16, height=16, encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1, channel-positions=(int)1, payload=(int)96" ! rtpL16depay ! audioconvert ! alsasink sync=false

使用RTP从麦克风编码音频:

gst-launch-0.10 pulsesrc ! audioconvert ! audio/x-raw-int,channels=1,depth=16,width=16,rate=22000 ! rtpL16pay  ! udpsink host=localhost port=5000