How to generate a GStreamer pipeline diagram: Difference between revisions

From RidgeRun Developer Wiki
Line 9: Line 9:
'''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:'''
Line 21: Line 23:
'''3. Run your pipeline, for example:'''
'''3. Run your pipeline, for example:'''


  # gst-launch-1.0 audiotestsrc num-buffers=1000 ! fakesink sync=false
<syntaxhighlight lang=bash>
gst-launch-1.0 audiotestsrc num-buffers=1000 ! fakesink sync=false
</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.
After the pipeline is over, you can see the .dot generated files with:
 
<syntaxhighlight lang=bash>
ls /tmp
</syntaxhighlight>
 
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 35: Line 44:
'''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 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:
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 cdefault image viewer with the command below or with your favorite image viewer.


  $ eog pipeline.png
<syntaxhighlight lang=bash>
xdg-open pipeline.png
</syntaxhighlight>


=== Helper Script ===
=== 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).
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>).


<pre>
<syntaxhighlight lang=bash>
DOT_FILES_DIR="fs/fs/graphs"
DOT_FILES_DIR="fs/fs/graphs"
PNG_FILES_DIR="fs/fs/graphs"
PNG_FILES_DIR="fs/fs/graphs"
Line 60: Line 73:
   dot -Tpng $DOT_FILES_DIR/$dot_file > $PNG_FILES_DIR/$png_file
   dot -Tpng $DOT_FILES_DIR/$dot_file > $PNG_FILES_DIR/$png_file
done
done
</pre>
</syntaxhighlight>


== Generate from a GStreamer application ==
== Generate from a GStreamer application ==

Revision as of 23:53, 17 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 cdefault image viewer with the command below or with your favorite image viewer.

xdg-open pipeline.png

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

Add this to your app after all the elements are created and linked.

GST_DEBUG_BIN_TO_DOT_FILE(pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")

and run the app like:

# GST_DEBUG_DUMP_DOT_DIR=. ./application

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

$ dot -Tpng pipeline.dot > pipeline.png

Open the pipeline.png

$ eog pipeline.png

See Also

GStreamer Pipeline Diagram Links