如何使用gstreamer通过RTSP传输MIC输入

时间:2018-01-23 05:29:58

标签: gstreamer rtsp rtp sdp gst-launch

我想从RTSP服务器流式传输麦克风输入。 我使用gstreamer1.0和gstreamer1.0-rtsp-server(v1.12.3)。

我尝试了以下命令,但管道创建的RTSP服务器未响应。我怎么流呢?

Tx: GST_DEBUG=3 test-launch "( alsasrc device="hw:0" ! audioconvert ! rtpL16pay )"
Rx: gst-launch-1.0 -q rtspsrc location=rtsp://10.5.41.11:8554/test ! decodebin ! audioconvert ! alsasink

结果(tx)是

stream ready at rtsp://127.0.0.1:8554/test
0:00:08.267067376   800 0x7601dd80 FIXME                default gstutils.c:3902:gst_pad_create_stream_id_internal:<alsasrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:08.274445501   800 0x7601dd80 WARN                    alsa pcm_hw.c:1250:snd_pcm_hw_get_chmap: alsalib error: Cannot read Channel Map ctl
: No such file or directory
0:00:08.299559918   800 0x7601dd80 WARN                 basesrc gstbasesrc.c:2939:gst_base_src_loop:<alsasrc0> error: Internal data stream error.
0:00:08.299722543   800 0x7601dd80 WARN                 basesrc gstbasesrc.c:2939:gst_base_src_loop:<alsasrc0> error: streaming stopped, reason not-linked (-1)
0:00:08.300421793   800 0x7601d920 WARN               rtspmedia rtsp-media.c:2433:default_handle_message: 0x7600e7d0: got error Internal data stream error. (../../../../gstreamer-1.12.3/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin0/GstAlsaSrc:alsasrc0:
streaming stopped, reason not-linked (-1))
0:00:08.300855501   800   0xdef890 WARN               rtspmedia rtsp-media.c:2728:wait_preroll: failed to preroll pipeline
0:00:08.301006459   800   0xdef890 WARN               rtspmedia rtsp-media.c:3032:gst_rtsp_media_prepare: failed to preroll pipeline
0:00:08.314116334   800   0xdef890 ERROR             rtspclient rtsp-client.c:977:find_media: client 0xdcfb40: can't prepare media
0:00:08.316345126   800   0xdef890 ERROR             rtspclient rtsp-client.c:2696:handle_describe_request: client 0xdcfb40: no media

我也尝试了以下命令。

Tx: GST_DEBUG=3 test-launch "( alsasrc device="hw:0" ! audio decodebin ! audioconvert ! rtpL16pay )"
Rx: gst-launch-1.0 -q rtspsrc location=rtsp://10.5.41.11:8554/test ! decodebin ! audioconvert ! alsasink

结果(tx):

stream ready at rtsp://127.0.0.1:8554/test
0:00:03.216280583   805 0x75f105b0 FIXME                default gstutils.c:3902:gst_pad_create_stream_id_internal:<alsasrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:03.222776083   805 0x75f105b0 WARN                    alsa pcm_hw.c:1250:snd_pcm_hw_get_chmap: alsalib error: Cannot read Channel Map ctl
: No such file or directory
0:00:03.238019083   805  0x1b82890 FIXME              rtspmedia rtsp-media.c:3581:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:03.256477500   805 0x75f105b0 WARN                 basesrc gstbasesrc.c:2939:gst_base_src_loop:<alsasrc0> error: Internal data stream error.
0:00:03.256641250   805 0x75f105b0 WARN                 basesrc gstbasesrc.c:2939:gst_base_src_loop:<alsasrc0> error: streaming stopped, reason not-linked (-1)
0:00:03.257567125   805 0x75f10150 WARN               rtspmedia rtsp-media.c:2433:default_handle_message: 0x75f0ea70: got error Internal data stream error. (../../../../gstreamer-1.12.3/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin0/GstAlsaSrc:alsasrc0:
streaming stopped, reason not-linked (-1))

PS:

第一个tx管道包括没有decodebin,rx的错误是503服务不可用。所以我认为tx管道是错误的。

第二个结果如下。

ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not get/set settings from/on resource.
Additional debug info:
../../../gst-plugins-good-1.8.3/gst/rtsp/gstrtspsrc.c(6361): gst_rtspsrc_setup_streams (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
SDP contains no streams
ERROR: pipeline doesn't want to preroll.

我认为这个错误说我应该将SDP添加到rx或tx管道。 如何将SDP添加到管道中?

要回答评论,我在这里描述命令。

Tx: GST_DEBUG=3 test-launch "( alsasrc device="hw:0" ! avenc_g722 ! rtpg722pay name=pay0 )"
Rx: gst-launch-1.0 rtspsrc location=rtsp://10.5.41.11:8554/test rtpjitterbuffer latency=0 ! fakesink

结果(Tx)的:

0:00:30.110267253  1979   0xe62830 WARN               rtspmedia rtsp-media.c:243                                    3:default_handle_message: 0xe90d20: got error Internal data stream error. (../..                                    /../../gstreamer-1.12.3/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop ():                                     /GstPipeline:media-pipeline/GstBin:bin2/GstAlsaSrc:alsasrc2:
streaming stopped, reason not-negotiated (-4))
0:00:30.118076170  1979 0x75f3b4f0 ERROR             rtspclient rtsp-client.c:97                                    7:find_media: client 0xe42c60: can't prepare media
0:00:30.119548961  1979 0x75f3b4f0 ERROR             rtspclient rtsp-client.c:26                                    96:handle_describe_request: client 0xe42c60: no media

结果(Rx)的:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://10.5.41.11:8554/test
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not read from resource.
Additional debug info:
../../../gst-plugins-good-1.8.3/gst/rtsp/gstrtspsrc.c(5670): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Got error response: 503 (Service Unavailable).
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

1 个答案:

答案 0 :(得分:1)

您需要为rtpL16pay设置名称,请尝试以下TX管道:

最初用audiotestsrc开始测试:

  

test-launch&#34;(audiotestsrc!audioconvert!rtpL16pay name = pay0)&#34;

并从您的麦克风(如果它在0处连接使用以下管道):

  

test-launch&#34;(alsasrc device =&#34; hw:0&#34;!audioparse!decodebin!audioconvert!audioresample!avenc_g722!rtpg722pay name = pay0)&#34;

对于RX,请尝试以下管道:

  

gst-launch-1.0 -v -e rtspsrc location = rtsp://127.0.0.1:8554 / test!   rtpjitterbuffer延迟= 100! rtpL16depay! audioconvert! alsasink