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

How to stream MIC input by RTSP with gstreamer

我想从 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

结果(发送):

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 ...

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

对于测试,最初从 audiotestsrc 开始:

test-launch "(audiotestsrc ! audioconvert ! rtpL16pay name=pay0 )"

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

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

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

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