GStreamer手把手入坑

一、简介

百度。

这里是我入坑的学习资料《GStreamer应用开发手册学习笔记之二》:
https://blog.csdn.net/fireroll/article/details/46859973

这里可参阅一些GStreamer安装、shell命令行:
https://www.cnblogs.com/dong1/p/10423743.html

这里是我参考的gstreamer接入rtsp博客《gstreamer如何接入RTSP流(IP摄像头)的代码范例》:
https://blog.csdn.net/quantum7/article/details/82151637?utm_source=blogxgwz0


二、安装

版本GStreamer-1.14.5

sudo apt install \
    libssl1.0.0 \
    libgstreamer1.0-0 \
    gstreamer1.0-tools \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-libav \
    libgstrtspserver-1.0-0 \
    libjansson4=2.11-1

三、命令行

gstreamer调用摄像头并显示:
gst-launch-1.0 rtspsrc location="rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0" ! rtph264depay ! avdec_h264 ! autovideosink
或:gst-launch-1.0 rtspsrc latency=2000 location="rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0" ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink

基于Jetson平台:

#----------------------- GStreamer use rtsp camera -----------------------
gst-launch-1.0 rtspsrc latency=20 location="rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0" ! rtph264depay ! h264parse ! avdec_h264 ! nveglglessink

#----------------------- use dsexample plugin -----------------------
# use mp4 files
gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream-4.0/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! m.sink_0 nvstreammux name=m batch-size=1 width=1280 height=720 ! nvvideoconvert ! dsexample full-frame=1 ! nvdsosd ! nvegltransform ! nveglglessink
# use rtsp camera
gst-launch-1.0 rtspsrc latency=2000 location="rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0" ! rtph264depay ! h264parse ! nvv4l2decoder ! m.sink_0 nvstreammux name=m batch-size=1 width=1280 height=720 ! nvvideoconvert ! dsexample full-frame=1 ! nvdsosd ! nvegltransform ! nveglglessink

使用gst-inspect-1.0命令,可以查看GStreamer有哪些插件:

./gst-inspect-1.0 -h
用法:
gst-inspect-1.0 [选项...] [ELEMENT-NAME | PLUGIN-NAME]

帮助选项:
-h, --help 显示帮助选项
--help-all 显示全部帮助选项
--help-gst 显示 GStreamer 选项

应用程序选项:
-a, --print-all 打印全部组件
-b, --print-blacklist 显示黑名单文件列表
--print-plugin-auto-install-info 显示机器可解析的指定插件或所有插件提供的特性列表。
与外部自动插件安装机制连接时有用
--plugin 列出插件信息
--exists Check if the specified element or plugin exists
--atleast-version When checking if an element or plugin exists, also check that its version is at least the version specified
-u, --uri-handlers 打印所支持的 URI 样式及它们的关联组件
--version Print version information and exit

四、学习代码

我将我学习GStreamer的程序代码提交到了Github,项目名gstreamer_learn
Github地址:https://github.com/tosonw/gstreamer_learn

gstreamer_learn

我用来学习GStreamer的程序,内部有多个demo,只依赖GStreamer,可以自己编译并运行、调试和学习。

依赖:GStreamer

sudo apt install \
    libssl1.0.0 \
    libgstreamer1.0-0 \
    gstreamer1.0-tools \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-libav \
    libgstrtspserver-1.0-0 \
    libjansson4=2.11-1

编译:

mkdir build
cd build
cmake ..
make

运行:

./demo_1_version_
./demo_2_init_
./demo_3_element_fac_
./demo_4_get_element_info_
./demo_5_link_elements_
./demo_6_pads_
./demo_8_helloworld_
./demo_gstreamer_rtsp_

五、gst插件

这个可以自行百度。
不过我是根据deepstream官方教程一步步了解的,具体还在研究中,如有需要请自行查阅:

官方文档《NVIDIA DeepStream插件手册》:https://docs.nvidia.com/metropolis/deepstream/dev-guide/DeepStream%20Development%20Guide/deepstream_custom_plugin.html#wwpID0E0TB0HA

你可能感兴趣的:(视频编解码)