Gstreamer推送摄像头数据到RTMP服务器的方法(SRS成功示例)

最近在研究如何将Linux中的视频数据推送到流媒体服务器,看到gstreamer还比较不错,于是试了一下
服务端用的SRS,RTMP推流,搭建非常简单,教程可参考:https://blog.csdn.net/qq_52514123/article/details/124845005

中间经历了各种报错吗,我放出来供后人参考
无法打开流的错误:

RROR: from element /GstPipeline:pipeline0/GstRTMPSink:rtmpsink0: Could not open resource for writing.
Additional debug info:
gstrtmpsink.c(293): gst_rtmp_sink_render (): /GstPipeline:pipeline0/GstRTMPSink:rtmpsink0:
Could not connect to RTMP stream “rtmp://192.168.1.146:1935/live1?key=12345 live=1” for writing
Execution ended after 0:00:10.850932699

未知原因报错:

ERROR: from element /GstPipeline:pipeline0/GstRTMPSink:rtmpsink0: Could not open resource for writing.
Additional debug info:
gstrtmpsink.c(293): gst_rtmp_sink_render (): /GstPipeline:pipeline0/GstRTMPSink:rtmpsink0:
Could not connect to RTMP stream “rtmp://192.168.1.146/live1” for writing
EOS on shutdown enabled – waiting for EOS after Error
Waiting for EOS…
ERROR: from element /GstPipeline:pipeline0/GstQueue:queue1: Internal data stream error.
Additional debug info:
gstqueue.c(988): gst_queue_handle_sink_event (): /GstPipeline:pipeline0/GstQueue:queue1:
streaming stopped, reason error (-5)

也是不知道啥错:

Additional debug info: gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming stopped, reason not-negotiated (-4) ERROR: pipeline doesn’t want to preroll.

协商报错:

ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn’t want to preroll.

下面开始教程

  1. 首先输入lsusb指令查看是否检测到摄像头,最好用cheese查看一下能否显示画面

在这里插入图片描述

1. 安装Gstreamer
这一步很简单,更新软件包后输入命令安装:
Install GStreamer on Ubuntu or Debian
Run the following command:

apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

具体见:gstreamer官网文档

2.通过gst-launch-1.0 推流

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw, format=YUY2, width=640, height=480, framerate=30/1 ! videoconvert ! x264enc tune=zerolatency ! flvmux streamable=true ! rtmpsink location='rtmp://SRS服务器IP地址:1935/live/stream_name'

其中,/dev/video0 是摄像头设备文件的路径,YUY2 是摄像头输出数据的格式,640x480 是摄像头输出数据的分辨率,30/1 是摄像头输出数据的帧率,stream_name 是你要推流的流名称。记得改服务器地址

执行后,显示如下,没有报错即为成功:
在这里插入图片描述

3.在SRS服务端查看
回到SRS控制界面,发现有新的流

点击预览,看到画面推流成功
在这里插入图片描述

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值