【问题标题】:Stream webcam with GStreamer (RTSP)使用 GStreamer (RTSP) 流式传输网络摄像头
【发布时间】:2020-03-22 21:09:00
【问题描述】:

我已通过 USB 电缆将Kodak PIXPRO SP360 4k camera 连接到 Jetson Nano 或 TX2。

我希望能够通过浏览器观看该视频,无论是使用 RTSP 流、Webrtc 还是其他方式。 只要它有效,它在技术方面如何运作并不重要。因此,如果您有任何想法或建议,请随时分享。

我目前正在尝试运行基本设置。

./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv ! video/x-raw, width=640, height=480, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1"

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! decodebin ! videoconvert ! xvimagesink

我收到错误提示

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://127.0.0.1:8554/test
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not get/set settings from/on resource.
Additional debug info:
gstrtspsrc.c(6999): gst_rtspsrc_setup_streams_start (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
SDP contains no streams
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
(test-launch:22440): GLib-GObject-WARNING **: 11:36:46.018: invalid cast from 'GstRtpH265Pay' to 'GstBin'

(test-launch:22440): GStreamer-CRITICAL **: 11:36:46.018: gst_bin_get_by_name: assertion 'GST_IS_BIN (bin)' failed

(test-launch:22440): GLib-GObject-WARNING **: 11:36:46.018: invalid cast from 'GstRtpH265Pay' to 'GstBin'

(test-launch:22440): GStreamer-CRITICAL **: 11:36:46.018: gst_bin_get_by_name: assertion 'GST_IS_BIN (bin)' failed

(test-launch:22440): GLib-GObject-WARNING **: 11:36:46.018: invalid cast from 'GstRtpH265Pay' to 'GstBin'

(test-launch:22440): GStreamer-CRITICAL **: 11:36:46.018: gst_bin_get_by_name: assertion 'GST_IS_BIN (bin)' failed

我还尝试了一个在 PC 上适用于我的选项,但我无法让它在 Jetson 上运行。设置如下。

https://github.com/ccrisan/streameye下载Streameye并运行:

netcat -l 8700 | ./streameye -p 1337

要发送我运行的网络摄像头流:

gst-launch-1.0 v4l2src device=/dev/video0 ! decodebin ! videoconvert ! videoscale ! videorate ! jpegenc quality=30 ! tcpclientsink host=127.0.0.1 port=8700

在此之后我得到:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3064): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:03.944998186
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

我的相机的这个命令的输出是:

v4l2-ctl -d /dev/video1 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
        Size: Discrete 3840x2160
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 2880x2880
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 2048x2048
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1440x1440
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1920x1080
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.200s (5.000 fps)

【问题讨论】:

    标签: gstreamer rtsp nvidia-jetson nvidia-jetson-nano


    【解决方案1】:

    如果您想流式传输它,最简单的方法是使用 gst-rtsp-launch,它是 GStreamer 预构建二进制文件的一部分:

    gst-rtsp-launch '( v4l2src device=/dev/video0 ! videoconvert ! queue ! x264enc tune="zerolatency" byte-stream=true bitrate=10000 ! rtph264pay name=pay0 pt=96 )'
    

    稍后您可以调整编解码器、比特率,但对我来说这已经足够了(可在 VLC 中播放 - rtsp://127.0.0.1:8554/test)

    【讨论】:

      【解决方案2】:

      像这样使用 -v 运行你的管道并显示结果:

      gst-launch-1.0 v4l2src device=/dev/video0 ! decodebin ! videoconvert ! videoscale ! videorate ! jpegenc quality=30 ! tcpclientsink host=127.0.0.1 port=8700 -v
      

      【讨论】:

      • ``` 将管道设置为暂停 ... 管道处于活动状态,不需要 PREROLL ... 错误:来自元素 /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:内部数据流错误。附加调试信息:gstbasesrc.c(3055):gst_base_src_loop ():/GstPipeline:pipeline0/GstV4l2Src:v4l2src0: 流停止,原因未协商 (-4) 错误:管道不想预滚动。将管道设置为 PAUSED ... 将管道设置为 READY ... 将管道设置为 NULL ... 释放管道 ... ```
      • 使用 -v 运行:在管道末尾添加 -v,然后运行它。
      • 最后有-v,它返回这个。我设法用streameye运行它,但它说jpeg太大了。我使用了这个管道 $ gst-launch-1.0 v4l2src device=/dev/video1 io-mode=2 !图像/JPEG,宽度=1280,高度=720,帧率=30/1! nvjpegdec!视频/x-raw! xvimagesink 我还发现那个解决方案对我不起作用,所以我需要使用 gst-rtsp-server。
      • 如果你想发送 rtp 你可以使用这个:gst-launch-1.0 v4l2src device=/dev/video0 ! rtpmjpegpay! udpsink 端口=2000 主机=127.0.0.1。您的 src(v4l2src 生成 jpeg,您不必转换为 jpeg)
      • 我的视频是 4k,3840x2160。当我尝试运行时,首先我得到:没有元素 rtmpjpegpay。当我删除该部分时,我得到:警告:从元素/GstPipeline:pipeline0/GstUDPSink:udpsink0:尝试发送大于最大大小的UDP数据包(1554753> 65507)附加调试信息:gstmultiudpsink.c(722):gst_multiudpsink_send_messages() : /GstPipeline:pipeline0/GstUDPSink:udpsink0: 原因:错误发送消息:消息太长
      猜你喜欢
      • 2022-06-13
      • 2023-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      • 2014-06-18
      相关资源
      最近更新 更多