2、Gstreamer生成pipeline流图

一、使用命令行

1、安装dot

 sudo apt-get install graphviz

2、添加到环境变量,文件夹路径可以随意改变

export GST_DEBUG_DUMP_DOT_DIR=/home/hiccup/gst_pipeline

3、运行管道

gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-raw, width=640, height=480, format=(string)YUY2" ! xvimagesink -e

管道结束后,您可以看到.dot生成的文件,并且“* PLAYING_PAUSED *”通常用于生成图表。

$  ls /tmp 
0.00.00.238129310-gst-launch.NULL_READY.dot
0.00.00.247064574-gst-launch.READY_PAUSED.dot
0.00.00.632677398-gst-launch.PAUSED_PLAYING.dot
0.00.05.464861472-gst-launch.PLAYING_PAUSED.dot
0.00.05.484623147-gst-launch.PAUSED_READY.dot

4、使用dot 生成png图片

dot -Tpng 0.00.05.464861472-gst-launch.PLAYING_PAUSED.dot > aa.png

pipeline构件图

  • 橘黄色:src element 和 src pad
  • 紫色:sink element 和 sink pad
  • 绿色:一般的element(除src element 和sink element外)

二、在应用程序中使用(C)

GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");
// 或者
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");

运行应用程序时前缀加上GST_DEBUG_DUMP_DOT_DIR=/home/hiccup/gst_pipeline

GST_DEBUG_DUMP_DOT_DIR=/home/hiccup/gst_pipeline ./application [参数1] [参数2] ...

三、在应用程序中使用(python)
首先安装依赖:sudo apt-get install graphviz。
1、在你要运行的py文件import的部分添加:

import os
os.environ["GST_DEBUG_DUMP_DOT_DIR"] = "/tmp"
os.putenv('GST_DEBUG_DUMP_DIR_DIR', '/tmp')

最后,在文件中快开始允许loop之前添加Gst.debug_bin_to_dot_file(pipeline, Gst.DebugGraphDetails.ALL, "pipeline")

osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)

Gst.debug_bin_to_dot_file(pipeline, Gst.DebugGraphDetails.ALL, "pipeline")

# start play back and listen to events
print("Starting pipeline \n")
pipeline.set_state(Gst.State.PLAYING)
try:
    loop.run()
except:
    pass
# cleanup
pipeline.set_state(Gst.State.NULL)

然后就跟上面的操作差不多了,使用dot命令转化为png即可
参考:
https://forums.developer.nvidia.com/t/python-deepstream-program-not-generating-dot-file/163837

posted @ 2022-04-18 18:01  hiccup_lh  阅读(823)  评论(0编辑  收藏  举报