代码之家  ›  专栏  ›  技术社区  ›  James Turner

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

  •  3
  • James Turner  · 技术社区  · 16 年前

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

    GStreamer提供了多种在网络上移动数据的方法-RTP、RTSP、GDP payloading、UDP和TCP服务器、客户机和套接字等等。网络上也有许多音频和视频流的例子,但实际上,它们似乎都不适合我;要么目标管道无法协商caps,要么我听到一个数据包,然后管道暂停,要么目标管道在没有可用数据的情况下立即退出。

    3 回复  |  直到 16 年前
        1
  •  5
  •   tilljoel    16 年前

    要调试此类问题,我将尝试:

    1. gst-launch audiotestsrc ! alsasink
    2. fakesink filesink 看看有没有缓冲区
    3. GST_DEBUG ,例如用 GST_DEBUG=GST_CAPS:4 或检查用途 *:2
    4. 使用wireshark查看是否发送了数据包

    这些管道为我工作:

    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
    
        2
  •  1
  •   enthusiasticgeek    14 年前

    使用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
    

    gst-launch-0.10 pulsesrc ! audioconvert ! audio/x-raw-int,channels=1,depth=16,width=16,rate=22000 ! rtpL16pay  ! udpsink host=localhost port=5000
    
        3
  •  0
  •   Sid Heroor    16 年前

    你能发布一些你尝试过的gst启动管道吗?这可能有助于理解你为什么会有问题。一般来说,RTP/RTSP应该很容易工作。

    编辑: 我能想到的几件事是 1.将host=localhost改为host=where是另一台linux机器的实际ip地址