使用GStreamer在本地网络上移动音频 [英] moving audio over a local network using GStreamer

查看:245
本文介绍了使用GStreamer在本地网络上移动音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在两台Linux机器之间移动实时音频,这两台机器都运行(基于我的)自定义软件,该软件基于Gstreamer构建. (该软件已经通过单独的基于TCP的协议在机器之间进行了其他通信-我提到这一点是在可靠的带外数据对解决方案有所帮助的情况下.)

I need to move realtime audio between two Linux machines, which are both running custom software (of mine) which builds on top of Gstreamer. (The software already has other communication between the machines, over a separate TCP-based protocol - I mention this in case having reliable out-of-band data makes a difference to the solution).

音频输入将是发送机上的麦克风/线路输入,普通音频输出将作为目的地的接收器; alsasrc和alsasink最有可能,尽管在测试中我一直使用audiotestsrc而不是真实的麦克风.

The audio input will be a microphone / line-in on the sending machine, and normal audio output as the sink on the destination; alsasrc and alsasink are the most likely, though for testing I have been using the audiotestsrc instead of a real microphone.

GStreamer提供了多种在网络上移动数据的方法-RTP,RTSP,GDP负载,UDP和TCP服务器,客户端和套接字,等等.网络上也有很多流音频和视频的示例-但实际上,这些示例似乎都不适合我.或者目标管道无法协商上限,或者我听到一个数据包,然后管道停顿,或者目标管道立即崩溃,没有可用数据.

GStreamer offers a multitude of ways to move data round over networks - RTP, RTSP, GDP payloading, UDP and TCP servers, clients and sockets, and so on. There's also many examples on the web of streaming both audio and video - but none of them seem to work for me, in practice; either the destination pipeline fails to negotiate caps, or I hear a single packet and then the pipeline stalls, or the destination pipeline bails out immediately with no data available.

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

In all cases, I'm testing on the command-line just gst-launch. No compression of the audio data is required - raw audio, or trivial WAV, uLaw or aLaw encoding is fine; what's more important is low-ish latency.

推荐答案

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

To debug that kind of problem i would try:

  1. 运行gst-launch audiotestsrc ! alsasink检查声音是否正常
  2. 使用fakesinkfilesink来查看是否有缓冲区
  3. 尝试使用GST_DEBUG查找管道问题,例如使用GST_DEBUG=GST_CAPS:4检查瓶盖或使用*:2检查以获取所有错误/警告
  4. 使用wireshark查看是否发送了数据包
  1. Run gst-launch audiotestsrc ! alsasink to checkthat sounds works
  2. Use a fakesink or filesink to see if we get any buffers
  3. Try to find the pipeline problem with GST_DEBUG, for example check caps with GST_DEBUG=GST_CAPS:4 or check use *:2 to get all errors/warnings
  4. Use wireshark to see if packets are sent

这些管道对我有用:

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

这篇关于使用GStreamer在本地网络上移动音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆