gstreamer tracer可以直接输出当前系统的开销、耗时、内存占用等状况。
使用tracer需要在debug中将tracer的打印开启。
GST_DEBUG=“GST_TRACER:7”
1. GST_DEBUG基础设定
设定打印等级
GST_DEBUG=2 //将log输出级别设定为2,WARNING
默认等级为0,即不输出任何信息。当我们需要输出log,通过设定GST_DEBUG变量的值来更改等级。对应等级参考下表
| # | Name | Description |
|---|---------|----------------------------------------------------------------|
| 0 | none | No debug information is output. |
| 1 | ERROR | Logs all fatal errors. These are errors that do not allow the |
| | | core or elements to perform the requested action. The |
| | | application can still recover if programmed to handle the |
| | | conditions that triggered the error. |
| 2 | WARNING | Logs all warnings. Typically these are non-fatal, but |
| | | user-visible problems are expected to happen. |
| 3 | FIXME | Logs all "fixme" messages. Those typically that a codepath that|
| | | is known to be incomplete has been triggered. It may work in |
| | | most cases, but may cause problems in specific instances. |
| 4 | INFO | Logs all informational messages. These are typically used for |
| | | events in the system that only happen once, or are important |
| | | and rare enough to be logged at this level. |
| 5 | DEBUG | Logs all debug messages. These are general debug messages for |
| | | events that happen only a limited number of times during an |
| | | object's lifetime; these include setup, teardown, change of |
| | | parameters, etc. |
| 6 | LOG | Logs all log messages. These are messages for events that |
| | | happen repeatedly during an object's lifetime; these include |
| | | streaming and steady-state conditions. This is used for log |
| | | messages that happen on every buffer in an element for example.|
| 7 | TRACE | Logs all trace messages. Those are message that happen very |
| | | very often. This is for example is each time the reference |
| | | count of a GstMiniObject, such as a GstBuffer or GstEvent, is |
| | | modified. |
| 9 | MEMDUMP | Logs all memory dump messages. This is the heaviest logging and|
| | | may include dumping the content of blocks of memory. |
+------------------------------------------------------------------------------+
单独设定某一元件等级
GST_DEBUG=2,audiotestsrc:6 //将audiotestsrc等级单独设定为6
以上支持通配符:
GST_DEBUG=2,audio*:6 //将所有audio开头的元件等级设定为6
将log输出到指定文件
GST_DEBUG_FILE=/home/gst/trace.log
更改输出通道
可以将log指定到某文件或者socket。
GST_TRACE_CHANNEL=stderr
输出管道图
GST_DEBUG_DUMP_DOT_DIR=/home/gst/
2. rusage
输出资源占用信息:
GST_TRACERS=“rusage”
$ GST_DEBUG="GST_TRACER:7" GST_TRACERS="rusage" /usr/bin/gst-play-1.0 ~/Videos/test1.mp4 ~/Videos/test1.mp4
...
0:00:00.109237154 15123 0x557d7cdac750 TRACE GST_TRACER :0:: thread-rusage, thread-id=(guint64)93997453985616, ts=(guint64)109234032, average-cpuload=(uint)151, current-cpuload=(uint)78, time=(guint64)16501669;
0:00:00.109243797 15123 0x557d7cdac750 TRACE GST_TRACER :0:: proc-rusage, process-id=(guint64)15123, ts=(guint64)109234032, average-cpuload=(uint)39, current-cpuload=(uint)32, time=(guint64)34465689;
0:00:00.109253587 15123 0x557d7cdac750 TRACE GST_TRACER :0:: thread-rusage, thread-id=(guint64)93997453985616, ts=(guint64)109250395, average-cpuload=(uint

GStreamer提供了一套强大的tracers工具,用于监控和分析系统开销、资源占用、内存泄漏和延迟等。通过设置GST_DEBUG环境变量和GST_TRACERS,可以输出详细的调试信息,例如rusage tracer显示CPU和内存使用情况,leaks tracer检测内存泄漏,latency tracer测量元素间的延迟。此外,stats tracer追踪缓冲区、事件、消息和查询,而gst-stats工具则能进一步统计和分析这些数据。借助gst-plot-traces.sh,可以将数据可视化。这些工具对于优化GStreamer应用的性能和诊断问题非常有用。
最低0.47元/天 解锁文章
870





