GStreamer debug and trace
Debug
Basic tutorial 11: Debugging tools
GStreamer pipelines can fail because an element cannot link, caps are wrong, timestamps are bad, one branch is slower than the other, or a sink is blocking the whole pipe. Debug tools help answer three questions:
- What elements are in the pipeline?
- What caps and buffers flow between them?
- Which element is slow or blocked?
Basic debug commands
Use gst-inspect-1.0 before building a pipe. It shows element pads, caps,
properties, and plugin information.
| Inspect an element | |
|---|---|
Use gst-launch-1.0 -v to print caps negotiation while the pipeline starts.
This is the fastest way to see the format that moves between elements.
| Print negotiated caps | |
|---|---|
Use GST_DEBUG when caps output is not enough. Level 2 prints warnings,
3 adds info, 4 adds debug messages, and higher levels are very noisy.
| Show warnings | |
|---|---|
| Debug only caps negotiation | |
|---|---|
Debug monitor
For large logs, use a debug log viewer instead of reading terminal output.
gst-debug-viewer can open a GStreamer debug log, filter by category, search
for warnings, and show the order of messages.
| Write a debug log | |
|---|---|
Pipeline graph
GStreamer can dump the pipeline graph to Graphviz .dot files. This is useful
for checking what decodebin, playbin, or dynamic pads created internally.
| Dump pipeline graph | |
|---|---|
| Convert graph to PNG | |
|---|---|
Open the generated image and check the real element chain, pad names, and caps.
Elements that help debug a pipeline
fakesink
Use fakesink to remove the real output from the test. If the pipeline works
with fakesink but not with autovideosink, the sink or display path is the
problem.
fpsdisplaysink
Use fpsdisplaysink to measure rendered FPS. It is useful for finding a slow
decoder, converter, encoder, or sink.
identity
identity passes buffers through and can print information about them. It is a
good probe point between two elements.
| Print buffers passing through identity | |
|---|---|
It can also sleep for each buffer, which is useful for simulating a slow element.
| Simulate a slow stage | |
|---|---|
queue
queue creates a new thread and decouples pipeline branches. Put queues around
suspected slow parts to see where buffering grows or where the pipe blocks.
| Debug a split pipeline with queues | |
|---|---|
If one branch is slow and there is no queue, it can block the other branch.
Finding a bottleneck
Start with a simple pipe and add one element at a time.
| Source only | |
|---|---|
| Add conversion | |
|---|---|
| Add encoder | |
|---|---|
If performance drops after adding one element, inspect that element first. Check its caps, properties, thread boundary, and whether the sink is synchronized to the clock.
Useful checks:
- Add
-vto verify caps. - Replace the sink with
fakesink. - Add
fpsdisplaysinkto measure FPS. - Add
identity silent=falsebefore and after the suspected element. - Add
queuebefore heavy branches. - Run with
GST_DEBUG=2and fix warnings first.
Trace
| from source to sink | |
|---|---|
GStreamer tracers measure runtime behavior. The latency tracer reports how long buffers take to move through the pipeline or through each element.
For long-running performance work, GstShark can collect and visualize tracing data such as latency, CPU usage, queue levels, and scheduling behavior.