Difference between revisions of "How to generate a GStreamer pipeline diagram"

From RidgeRun Developer Connection
Jump to: navigation, search
m (Adding reference to the main Gstreamer Debugging page.)
 
(29 intermediate revisions by 7 users not shown)
Line 1: Line 1:
= Introduction =
+
<seo title="GStreamer Pipeline Diagram | GStreamer Pipeline Editor | RidgeRun" titlemode="replace" metakeywords="GStreamer, Linux SDK, Linux BSP,  Embedded Linux, Device Drivers, NVIDIA, Xilinx, TI, NXP, Freescale, embedded Linux driver development, Linux software development, embedded Linux sdk, Pipeline diagram, GStreamer pipeline diagram, Pipeline Editor, GStreamer Pipeline Editor" metadescription="Find a step-by-step guide for generating a useful GStreamer pipeline diagram in the RidgeRun Developer Wiki."></seo>
  
This page will allow you to create a useful diagram of your pipeline, as described in http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+11%3A+Debugging+tools.
+
== Introduction ==
  
= Steps =
+
This page will allow you to create a useful diagram of your pipeline, as described in [https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html?gi-language=c. GStreamer's Basic Tutorial].
 +
 
 +
== Steps ==
  
 
'''1. Install ''dot'':'''
 
'''1. Install ''dot'':'''
  
  sudo apt-get install graphviz
+
<syntaxhighlight lang=bash>
 +
sudo apt-get install graphviz
 +
</syntaxhighlight>
  
The "''dot''" command is available in the "''graphviz''" package.
+
The <code>dot</code> command is available in the <code>graphviz</code> package.
  
 
'''2. In the target, run:'''
 
'''2. In the target, run:'''
  
  # export GST_DEBUG_DUMP_DOT_DIR=/tmp/
+
<syntaxhighlight>
 +
export GST_DEBUG_DUMP_DOT_DIR=/tmp/
 +
</syntaxhighlight>
  
This will place the .dot generated files in your /tmp/ directory, you can change that directory if you need to.
+
This will place the .dot generated files in your <code>/tmp/</code> directory, you can change that directory if you need to.
  
 
'''3. Run your pipeline, for example:'''
 
'''3. Run your pipeline, for example:'''
  
  # gst-launch audiotestsrc num-buffers=1000 ! fakesink sync=false
+
<syntaxhighlight>
 +
gst-launch-1.0 audiotestsrc num-buffers=1000 ! fakesink sync=false
 +
</syntaxhighlight>
 +
 
 +
After the pipeline is over, you can see the .dot generated files with:
 +
 
 +
<syntaxhighlight lang=bash>
 +
ls /tmp
 +
</syntaxhighlight>
  
After the pipeline is over, you can see the .dot generated files, and the "''*PLAYING_PAUSED*''" one is typically used to generate the diagram.
+
The "''PLAYING_PAUSED''" one is typically used to generate the diagram.
  
  # ls /tmp
 
 
   0.00.00.972540004-gst-launch.NULL_READY.dot
 
   0.00.00.972540004-gst-launch.NULL_READY.dot
 
   0.00.01.051387461-gst-launch.READY_PAUSED.dot
 
   0.00.01.051387461-gst-launch.READY_PAUSED.dot
Line 33: Line 46:
 
'''4. In your host machine, generate the diagram from the dot file'''  
 
'''4. In your host machine, generate the diagram from the dot file'''  
  
This step implies you know how to transfer the .dot file from your target to your host machine. Once you've done that, you can generate the .png image using the "''dot''" command in your host:
+
This step implies that you know how to transfer the .dot file from your target to your host machine. Once you've done that, you can generate the .png image using the <code>dot</code> command in your host:
  
  $ dot -Tpng 0.00.24.846778049-gst-launch.PLAYING_PAUSED.dot > pipeline.png
+
<syntaxhighlight lang=bash>
 +
dot -Tpng 0.00.12.187852589-gst-launch.PLAYING_PAUSED.dot > pipeline.png
 +
</syntaxhighlight>
  
 
'''5. Open up your image'''
 
'''5. Open up your image'''
  
Once the image has been created, you can open it with your favorite image viewer, for example:
+
Once the image has been created, you can open it using the default image viewer with the command below or with your favorite image viewer.
 +
 
 +
<syntaxhighlight lang=bash>
 +
xdg-open pipeline.png
 +
</syntaxhighlight>
 +
 
 +
You will see a graph like the one in Figure 1.
 +
 
 +
<br>
 +
[[File:pipeline_dot_graph.png|thumb| center | 650px | Figure 1: Pipeline's graph]]
 +
<br>
 +
 
 +
=== Helper Script ===
 +
 
 +
Sometimes you can get a lot of different DOT files generated. If you want to convert each one of them to PNG pictures, you can use this script. Specify the folder where your DOT files are (<code>DOT_FILES_DIR</code>), and the folder where you want to place the generated PNG files (<code>PNG_FILES_DIR</code>).
 +
 
 +
<syntaxhighlight lang=bash>
 +
DOT_FILES_DIR="fs/fs/graphs"
 +
PNG_FILES_DIR="fs/fs/graphs"
 +
 
 +
DOT_FILES=`ls $DOT_FILES_DIR | grep dot`
 +
 
 +
for dot_file in $DOT_FILES
 +
do
 +
  png_file=`echo $dot_file | sed s/.dot/.png/`
 +
  dot -Tpng $DOT_FILES_DIR/$dot_file > $PNG_FILES_DIR/$png_file
 +
done
 +
</syntaxhighlight>
 +
 
 +
== Generate from a GStreamer application ==
 +
 
 +
We will see how to create the do file from a C and Python application.
 +
 
 +
=== C ===
 +
Add this to your app after all the elements are created and linked and before you set your pipeline to <code>NULL</code>:
 +
 
 +
<syntaxhighlight lang=C>
 +
GST_DEBUG_BIN_TO_DOT_FILE(pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")
 +
</syntaxhighlight>
 +
 
 +
And run the app like:
 +
 
 +
<syntaxhighlight>
 +
GST_DEBUG_DUMP_DOT_DIR=. ./application
 +
</syntaxhighlight>
 +
 
 +
=== Python ===
 +
For Python, use the following:
 +
 
 +
<syntaxhighlight lang=C>
 +
Gst.debug_bin_to_dot_file(pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")
 +
</syntaxhighlight>
 +
 
 +
And run the app like:
 +
 
 +
<syntaxhighlight>
 +
GST_DEBUG_DUMP_DOT_DIR=. python3 ~/application.py
 +
</syntaxhighlight>
 +
 
 +
=== Convert to PNG ===
 +
Where you ran the application, you can find a file named <code>pipeline.dot</code>, move it to your computer and convert it to PNG format:
 +
 
 +
<syntaxhighlight>
 +
dot -Tpng pipeline.dot > pipeline.png
 +
</syntaxhighlight>
 +
 
 +
Open the pipeline.png
 +
 
 +
<syntaxhighlight>
 +
xdg-open pipeline.png
 +
</syntaxhighlight>
 +
 
 +
You should see a graph like the one shown in Figure 1.
  
  $ eog pipeline.png
+
== See Also ==
  
= See Also =
+
*[[GStreamer_Debugging|GStreamer Debugging]]
  
[[GStreamer_Debugging|Gstreamer Debugging]]
+
== GStreamer Pipeline Diagram Links ==
  
= References =
+
*[https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html?gi-language=c#getting-pipeline-graphs GStreamer Debugging Tools Tutorial].
  
[http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+11%3A+Debugging+tools Gstreamer Debugging Tools Tutorial]. Section "Getting pipeline graphs".
+
*[http://en.wikipedia.org/wiki/DOT_language DOT Language]
  
[http://en.wikipedia.org/wiki/DOT_language DOT Language]
+
*[http://www.graphviz.org/ Graph Visualization Software]
  
[http://www.graphviz.org/ Graph Visualization Software]
+
{{ContactUs}}
  
 
[[Category:HowTo]] [[Category:GStreamer]]
 
[[Category:HowTo]] [[Category:GStreamer]]

Latest revision as of 16:36, 27 July 2023

Introduction

This page will allow you to create a useful diagram of your pipeline, as described in GStreamer's Basic Tutorial.

Steps

1. Install dot:

sudo apt-get install graphviz

The dot command is available in the graphviz package.

2. In the target, run:

export GST_DEBUG_DUMP_DOT_DIR=/tmp/

This will place the .dot generated files in your /tmp/ directory, you can change that directory if you need to.

3. Run your pipeline, for example:

gst-launch-1.0 audiotestsrc num-buffers=1000 ! fakesink sync=false

After the pipeline is over, you can see the .dot generated files with:

ls /tmp

The "PLAYING_PAUSED" one is typically used to generate the diagram.

 0.00.00.972540004-gst-launch.NULL_READY.dot
 0.00.01.051387461-gst-launch.READY_PAUSED.dot
 0.00.01.074729712-gst-launch.PAUSED_PLAYING.dot
 0.00.12.187852589-gst-launch.PLAYING_PAUSED.dot
 0.00.12.201485839-gst-launch.PAUSED_READY.dot
 psplash_fifo

4. In your host machine, generate the diagram from the dot file

This step implies that you know how to transfer the .dot file from your target to your host machine. Once you've done that, you can generate the .png image using the dot command in your host:

dot -Tpng 0.00.12.187852589-gst-launch.PLAYING_PAUSED.dot > pipeline.png

5. Open up your image

Once the image has been created, you can open it using the default image viewer with the command below or with your favorite image viewer.

xdg-open pipeline.png

You will see a graph like the one in Figure 1.


Figure 1: Pipeline's graph


Helper Script

Sometimes you can get a lot of different DOT files generated. If you want to convert each one of them to PNG pictures, you can use this script. Specify the folder where your DOT files are (DOT_FILES_DIR), and the folder where you want to place the generated PNG files (PNG_FILES_DIR).

DOT_FILES_DIR="fs/fs/graphs"
PNG_FILES_DIR="fs/fs/graphs"

DOT_FILES=`ls $DOT_FILES_DIR | grep dot`

for dot_file in $DOT_FILES
do
  png_file=`echo $dot_file | sed s/.dot/.png/`
  dot -Tpng $DOT_FILES_DIR/$dot_file > $PNG_FILES_DIR/$png_file
done

Generate from a GStreamer application

We will see how to create the do file from a C and Python application.

C

Add this to your app after all the elements are created and linked and before you set your pipeline to NULL:

GST_DEBUG_BIN_TO_DOT_FILE(pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")

And run the app like:

GST_DEBUG_DUMP_DOT_DIR=. ./application

Python

For Python, use the following:

Gst.debug_bin_to_dot_file(pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")

And run the app like:

GST_DEBUG_DUMP_DOT_DIR=. python3 ~/application.py

Convert to PNG

Where you ran the application, you can find a file named pipeline.dot, move it to your computer and convert it to PNG format:

dot -Tpng pipeline.dot > pipeline.png

Open the pipeline.png

xdg-open pipeline.png

You should see a graph like the one shown in Figure 1.

See Also

GStreamer Pipeline Diagram Links


RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us

OOjs UI icon message-progressive.svg Contact Us

Visit our Main Website for the RidgeRun Products and Online Store. RidgeRun Engineering informations are available in RidgeRun Professional Services, RidgeRun Subscription Model and Client Engagement Process wiki pages. Please email to support@ridgerun.com for technical questions and contactus@ridgerun.com for other queries. Contact details for sponsoring the RidgeRun GStreamer projects are available in Sponsor Projects page. Ridgerun-logo.svg
RR Contact Us.png