• 基于gstreamer的rtsp推流 (USB摄像头)


    一. 配置gstreamer环境

    参考上篇文章 :ubuntu16.04上安装gstreamer

    二. 安装gstreamer-rtsp-server

    1. git clone -b 1.8 https://github.com/GStreamer/gst-rtsp-server.git //下载源码
    2. cd gst-rtsp-server
    3. ./autogen.sh
    4. sudo make
    5. sudo make install

    三、读取usb摄像头并推rtsp流 

    1.  测试

    (1) 切换到examples目录:cd examples

    (2) 编译   

    gcc test-launch.c -o test $(pkg-config --cflags --libs gstreamer-rtsp-server-1.0 gstreamer-1.0)

    (3) 搭建Rtsp Server:./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"
    (4) 播放rtsp流:gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test

    2. usb相机

    (1) 切换到examples目录:cd examples

    (2) 编译   

    gcc test-launch.c -o test $(pkg-config --cflags --libs gstreamer-rtsp-server-1.0 gstreamer-1.0)

    (3) 搭建Rtsp Server:

    ./test --gst-debug-level=3 "( v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=2592, height=600, framerate=30/1 ! queue ! x264enc bitrate=10240 !  rtph264pay name=pay0 pt=96 )"
    (4) 播放rtsp流:gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test

    或者  gst-launch-1.0 playbin uri= rtsp://127.0.0.1:8554/test uridecodebin0::source::latency=0

    3. gstreamer的常用命令

    1. // usb 相机
    2. gst-launch-1.0 v4l2src ! autovideosink
    3. gst-launch-1.0 v4l2src device=/dev/video0 ! autovideosink
    4. gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=720, height=720 ! autovideosink -v
    5. gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=720, height=720 ! xvimagesink -ev
    6. // home/zhy/Downloads/soft/GStreamer/gst-rtsp-server-1.16.0/examples
    7. 编译
    8. gcc test-launch.c -o test $(pkg-config --cflags --libs gstreamer-rtsp-server-1.0 gstreamer-1.0)
    9. 推流
    10. ./test "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"
    11. // rtsp推流
    12. ./test --gst-debug-level=3 "( v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=2592, height=600, framerate=30/1 ! queue ! x264enc bitrate=10240 ! rtph264pay name=pay0 pt=96 )"
    13. // rtsp 拉流
    14. gst-launch-1.0 playbin uri= rtsp://127.0.0.1:8554/test uridecodebin0::source::latency=0
    15. // rtsp推流加入时间
    16. ./test "( v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=2592, height=600, framerate=30/1 ! timeoverlay ! tee name=vsrc vsrc. ! queue ! videoconvert ! ximagesink vsrc. ! queue ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96 )"

  • 相关阅读:
    使用原生 cookieStore 方法,让 Cookie 操作更简单
    02 栈的原理与使用
    在更一般意义上验算移位距离和假设
    【SpringBoot笔记28】SpringBoot集成ES数据库之操作doc文档(创建、更新、删除、查询)
    嵌入式面试常见问题(三)
    python之word文档生成
    Java基础28(方法重载)
    前后端分离时后端shiro权限认证
    AIE聚甲基丙烯酸甲酯PMMA微球/聚苯乙烯包覆聚AIE微球/AIE聚四苯基乙烯自由基溶液聚合微球研究
    【Python入门五】第三方库(包)介绍
  • 原文地址:https://blog.csdn.net/zhngyue123/article/details/126362312