Basic tutorial
element -> pad -> caps 包含关系
Basic tutorial 7: Multithreading and Pad Availability
Request pads
To request (or release) pads in the PLAYING
or PAUSED
states, you need to take additional cautions (Pad blocking) which are not described in this tutorial. It is safe to request (or release) pads in the NULL
or READY
states, though.
多管道播放
- 单播放
gst-launch-1.0 filesrc location=/home/xuleilx/Music/123.mp3 ! decodebin ! autoaudiosink - 单显示
gst-launch-1.0 filesrc location=/home/xuleilx/Music/123.mp3 ! decodebin ! wavescope ! videoconvert ! autovideosink - 播放+显示
gst-launch-1.0 filesrc location=/home/xuleilx/Music/123.mp3 ! decodebin ! tee name=t ! queue ! autoaudiosink t. ! queue ! wavescope ! videoconvert ! autovideosink - 修改显示范围,增加个capsfilter
gst-launch-1.0 filesrc location=/home/xuleilx/Music/123.mp3 ! decodebin ! tee name=t ! queue ! autoaudiosink t. ! queue ! wavescope ! capsfilter caps=”video/x-raw, format=BGRx,width=1280, height=720, framerate=30/1” ! videoconvert ! autovideosink
注意:
playbin的flags的vis有类似功能
Basic tutorial 8: Short-cutting the pipeline
主要通过appsrc
,appsink
实现,截取管道中的数据。
This tutorial expands Basic tutorial 7: Multithreading and Pad Availability in two ways: firstly, the audiotestsrc
is replaced by an appsrc
that will generate the audio data. Secondly, a new branch is added to the tee
so data going into the audio sink and the wave display is also replicated into an appsink
. The appsink
uploads the information back into the application, which then just notifies the user that data has been received, but it could obviously perform more complex tasks.
Basic tutorial 10: GStreamer tools
三大利器,可以参照其源码实现想要的功能
1 | gst-launch-1.0 |
Basic tutorial 11: Debugging tools
Printing debug information
The debug log
The first category is the Debug Level, which is a number specifying the amount of desired output:
1 | | # | Name | Description | |
设置插件的日志等级
GST_DEBUG=2,audiotestsrc:6
支持正则表达式
GST_DEBUG=2,audio*:6
显示所有插件的日志等级:
gst-launch-1.0 --gst-debug-help
Gstreamer日志输出文件,默认输出到终端
export GST_DEBUG_FILE=/tmp/gst.log
Adding your own debug information
Use the GST_ERROR()
, GST_WARNING()
, GST_INFO()
, GST_LOG()
and GST_DEBUG() macros. They accept the same parameters as printf, and they use the default category (default will be shown as the Debug category in the output log).
Getting pipeline graphs
环境变量
export GST_DEBUG_DUMP_DOT_DIR=/tmp/
代码中
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(mypipeline), GST_DEBUG_GRAPH_SHOW_ALL, "test");
生成/tmp/test.dot文件,用vscode安装Graphviz Preview可查看
Basic tutorial 12: Streaming
对于流媒体来说,buffer是通用解决方案。gstreamer提供了queue、queue2和multiqueue1
2gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message", G_CALLBACK (cb_message), &data);
Live streams cannot be paused, so they behave in PAUSED
state as if they were in the PLAYING
state. Setting live streams to PAUSED
succeeds, but returns GST_STATE_CHANGE_NO_PREROLL
, instead of GST_STATE_CHANGE_SUCCESS
to indicate that this is a live stream. We are receiving the NO_PREROLL
return code even though we are trying to set the pipeline to PLAYING
, because state changes happen progressively (from NULL to READY, to PAUSED
and then to PLAYING
).
For the second network issue, the loss of clock, we simply set the pipeline to PAUSED and back to PLAYING, so a new clock is selected, waiting for new media chunks to be received if necessary.
Basic tutorial 14: Handy elements
Bins
playbin
uridecodebin
decodebin
File input/output
filesrc
filesink
Network
souphttpsrc
Test media generation
videotestsrc
audiotestsrc
Video adapters
videoconvert
videorate
videoscale
Audio adapters
audioconvert
audioresample
audiorate
Multithreading
queue
queue2
multiqueue
tee
Capabilities
capsfilter
typefind
Debugging
fakesink
identity