GStreamer has a simple feature to enable tracing, allowing the developer to do basic debugging. These can be done in two ways:
- Adding the parameter --gst-debug=LIST to the pipeline (a pipeline is a executed gst-launch command)
- Prepending the environment variable GST_DEBUG=LIST'
LIST is a a comma-separated argument, indicating the GStreamer elements to trace. For example, if one needs to trace the sink element
$ GST_DEBUG=*sink*:5 gst-launch playbin2 uri=file:///sample.avi
$ gst-launch playbin2 uri=file:///sample.avi --gst-debug=*sink*:5
Both commands produces the same log. In case want to trace for than one element, so can simple add the <element>:5, for example
$ GST_DEBUG=mfw_v4lsink:5,vpudec:5 gst-launch playbin2 uri=file:///sample.avi
The number 5 indicates the log category, where 5 is the highest (the most verbose log you can get) and 0 produces no output (5=LOG, 4=DEBUG, 3=INFO, 2=WARN, 1=ERROR).
Log can be huge in each pipeline run. One way to filter it is using the grep command. Before grepping, one needs to redirect the standard error to the standard output (GStreamer log goes always to stderr), so
$ GST_DEBUG=mfw_v4lsink:5,vpudec:5 gst-launch playbin2 uri=file:///sample.avi 2>&1 | grep <filter string>
In case the log needs to be shared, it is important to remove the 'color' of the log, again, one just needs to add the parameter --gst-debug-no-color or prepend the env variable GST_DEBUG_NO_COLOR=1
More shell variables that GStreamer react, can be found here https://developer.gnome.org/gstreamer/0.10/gst-running.html