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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章