一步一步创建GStreamer插件(ZZ)
PythonGstreamer入门

PythonGstreamer入门历时一个月的Python Gstreamer入门阶段接近尾声,在这里总结一下自己的学习历程。
首先感谢一下Andy同学和Stephen老师的帮助和指导。
(根据后续学习持续更新)1.基础知识学习阶段首先需要了解Gstreamer是什么,有哪些基本的内容,element、pad、bin、pipeline各是什么,其中又有哪些分类。
这里推荐Gsteamer的官方文档进行学习,可以去Gstreamer官网寻找英文文档,也可以直接搜索Gstreamer应用开发手册寻找中文版。
Gstreamer是使用C语言编写的框架,网络上关于Gstreamer的资料也是C语言编写居多(这也是我想写一篇自己的Python Gstreamer 学习历程的原因之一),不过不管是什么语言编写Gstreamer程序,基本的思路都是一样的,只是语句的表达方式不同而已,关于C语言和Python语言的函数对照表我后面也有提供。
这里推荐一个翻译的Gstreamer基础教程、播放教程博客:Gstreamer基础教程常用知识总结:gstreamer知识总结2.播放功能实现思路想要播放视频首先需要理解视频音频的编码与封装相关知识,这里推荐一个视音频编解码相关博客:视音频编解码技术零基础学习方法一个mkv视频的形成过程为:视音频原始数据——>音视频编码形成压缩数据——>音视频封装为MKV等格式视频。
相对应的我们播放一个视频就需要对这个过程翻转:MKV视频——>解封装——>解码——>播放。
图解:3.播放功能代码实现与资料对于Gstreamer的安装,Ubuntu可能会自带1.0版本,如果查找不到部分元件,可以搜索这些元件所属的插件包,这里提供一个元件和Gstreamer插件包对应的文档:gstreamer插件下面根据顺序介绍一下我编写代码的过程以及部分代码:(1)使用playbin实现对音视频的播放playbin是一个集成的箱柜可以直接用来播放多种音视频。
gstreamer 插件参数用法

gstreamer 插件参数用法GStreamer 是一个开源的跨平台多媒体处理框架,它提供了许多插件来实现各种音视频处理任务。
插件参数是 GStreamer 插件的一种配置方式,通过修改插件参数,我们可以自定义插件的行为以满足特定需求。
在使用 GStreamer 插件时,我们可以通过 `gst-launch-1.0` 或编程语言(如Python)的方式来配置插件参数。
下面是一些常见的插件参数用法示例:1. element 参数:许多插件包含多个 element,我们可以使用元素名称来配置参数。
例如,使用 `v4l2src` 插件获取视频流时,可以通过 `device=/dev/video0` 参数指定使用的视频设备。
2. property 参数:插件的属性可以通过 property 参数来修改。
例如,使用`alsasink` 插件播放音频时,可以通过 `device=hw:0` 参数指定使用的音频设备。
3. caps 参数:caps 是 GStreamer 中一种用于描述媒体流格式的机制。
我们可以通过 caps 参数来配置输入或输出媒体流的格式。
例如,使用 `autovideosink` 插件显示视频时,可以通过 `caps=video/x-raw, width=1280, height=720` 参数指定视频的分辨率。
4. signal 参数:有些插件会发出信号来通知应用程序当前的状态或事件。
我们可以通过 signal 参数来订阅这些信号并进行相应的处理。
例如,使用 `souphttpsrc` 插件下载网络视频时,可以通过 `signal-handoffs=true` 参数来处理信号,以在视频切换时执行特定的操作。
5. pipeline 参数:我们可以通过 pipeline 参数来连接多个插件并配置它们之间的数据流。
例如,使用 `gst-launch-1.0` 启动一个命令行管道时可以通过 `--gst-pipeline="videotestsrc ! autovideosink"` 参数指定数据流的处理方式。
GStreamer插件开发指南

GStreamer插件开发指南GStreamer是一个功能强大的开放源代码多媒体框架,用于处理和播放各种类型的媒体数据。
GStreamer插件是用于扩展GStreamer功能的模块,可以添加新的元件、过滤器和其他处理模块,以满足特定的需求。
1. 了解GStreamer框架:熟悉GStreamer的核心概念、基本组件和数据流模型是开发插件的基础。
阅读GStreamer的文档和教程,获取关于GStreamer的基本知识。
2.确定插件的功能:确定你希望新插件实现的功能和目标。
这可以是一个新的音频或视频处理算法,或者一个特定格式的文件解码器。
确保你的目标明确和可行。
3. 构建插件的框架:在开始实现具体功能之前,需要创建插件的框架。
这包括定义插件的接口、实例化对象和设置参数。
使用GStreamer提供的插件模板,使插件具备GObject的特性。
4. 实现插件的功能:根据插件的目标,实现相应的功能。
这可以是一个音频或视频处理算法、一个文件解码器或一个特定格式的编码器。
根据GStreamer的架构,将功能以数据流的形式连接到其他元件。
5. 调试和测试插件:在完成插件功能的实现后,进行调试和测试工作。
使用GStreamer提供的调试工具和技术,验证插件的正确性和稳定性。
这可能涉及创建测试文件、分析数据流、查找性能问题等。
6. 文档和发布插件:为你的插件创建文档,包括插件的功能、接口和使用方法。
将插件发布到GStreamer的插件仓库或其他适当的发布平台,以供其他开发者和用户使用。
7.迭代和改进插件:随着时间的推移和用户的反馈,可能需要对插件进行迭代和改进。
收集用户反馈,修复问题和改进插件的性能和功能。
GStreamer插件的开发是一个复杂的过程,需要有一定的编程和多媒体处理经验。
通过学习和研究现有的GStreamer插件,你可以更好地理解和掌握插件开发的技巧和方法。
通过不断实践和改进,你可以开发出高质量和有用的GStreamer插件。
gstreamer plugin process

Gstreamer Plugin创建全过程(以filesink插件为例)Gstreamer中pad支持两种schedule方式:docs/design/part-activation.txtpush-based scheduling: 这种scheduling方法中,downstream elements的sink pad上需要定义chain函数(gst_pad_set_chain_function ),upstream elements调用这个chain函数来完成将buffer从upstream(source pad)到downstream elements(sink pad)的传递。
这种scheduling方式中source elements递归调用downstream elements的chain函数,最后一直调用到目的elements的才能函数。
(由于chain函数是定义在sink pad上,而source element是没有sink pad的,因此source element是不提供chain函数的).调用的顺序是从sink element到source element。
(递归调用).在这种模式下,upstream elements通过调用downstream elements sink pad上定义的chain函数主动的将数据传输给downstream elements,因此数据驱动是由upstream element发起的。
一. 创建插件模板gst-launch和gst-inspect是开发插件中比较重要的两个工具。
其中,gst-inspcet用来查看插件信息以及检测插件是否创建成功。
gst-launch用来播放插件命令。
如:gst-launch-1.0 filesrclocation=/home/ssl/music.mp3 ! mad ! filesink ! autoaudiosink (其中filesink是我们自己创建的插件模板或者插件)(一般情况下,初步安装成功的ubuntu系统都会自带gstreamer-0.10版本,但是有写基础的插件等都需要安装。
使用Gstreamer作为数据源输出视频数据III填充数据

使用Gstreamer作为数据源输出视频数据III填充数据GStreamer是一个功能强大的开源框架,用于构建流媒体应用程序。
它提供了一种简单灵活的方式来处理音频和视频数据流。
使用GStreamer 作为数据源输出视频数据可以帮助我们更好地理解如何使用这个框架来构建流媒体应用程序。
在下面的内容中,我将详细介绍如何使用GStreamer 来填充视频数据。
首先,我们需要安装GStreamer框架和相关的插件。
可以通过以下命令在Linux系统上安装GStreamer:```sudo apt-get install gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly```安装完成后,可以通过运行以下命令检查是否成功安装:```gst-inspect-1.0```现在,我们可以开始使用GStreamer来填充视频数据了。
下面是一个示例代码:```pythonimport gigi.require_version('Gst', '1.0')from gi.repository import GObject, GstGObject.threads_initGst.init(None)pipeline = Gst.parse_launch"videotestsrc pattern=ball ! videoconvert ! autovideosink"pipeline.set_state(Gst.State.PLAYING)while True:#在此处填充视频数据pass```在上面的示例中,我们创建了一个视频测试源(videotestsrc),以球形图案填充视频数据。
gstreamer使用进阶

gstreamer使用进阶gstreamer很牛逼,让多媒体应用程序的开发变的更加简单,但是,也正是由于gstreamer对很多细节的隐藏,使得我们很容易把多媒体编程想得过于简单。
关于gst-launch的使用,这里不做教学,初次接触者可以自行google。
然后,请准备一个摄像头,下面我举的例子,都会用到。
先罗列出一堆例子--gst-launch-0.10 v4l2src ! ximagesinkgst-launch-0.10 v4l2src ! xvimagesinkgst-launch-0.10 v4l2src ! ffmpegcolorspace ! ximagesinkgst-launch-0.10 v4l2src ! ffmpegcolorspace ! xvimagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-rgb' ! ximagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv' ! ximagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-rgb' ! xvimagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv' ! xvimagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv' ! ffmpegcolorspace ! ximagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv' ! ffmpegcolorspace ! xvimagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv,format=(fourcc)YV12' ! xvimagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv,format=(fourcc)YUY2' ! xvimagesinkgst-launch-0.10 v4l2src ! 'video/x-raw-yuv,format=(fourcc)YV12' ! ffmpegcolorspace ! xvimagesink gst-launch-0.10 v4l2src ! 'video/x-raw-yuv,format=(fourcc)YUY2' ! ffmpegcolorspace ! xvimagesink然后我提出一个问题---上面这些例子,哪些可以正确执行,哪些不可以?不可以的原因是什么?如果你能够回答我提出的问题,那说明你对视频这一部分已经很清楚了。
gstreamer介绍及使用

gstreamer介绍及使⽤⼀、gstreamer介绍Gstreamer是⼀个⽀持Windows,Linux,Android, iOS的跨平台的多媒体框架,应⽤程序可以通过管道(Pipeline)的⽅式,将多媒体处理的各个步骤串联起来,达到预期的效果。
每个步骤通过元素(Element)基于GObject对象系统通过插件(plugins)的⽅式实现,⽅便了各项功能的扩展。
⼆、gstreamer安装ubuntu下gstreamer安装命令为:sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio这个命令主要是安装gstreamer的各种插件包,这些包中包含了很多插件,如gstreamer1.0-plugins-base是基础插件包,gstreamer1.0-plugins-good是⾼质量的采⽤LGPL授权的插件包。
通过gst-inspect-1.0命令看⼀下qtdemux插件的信息,如下所⽰:红框中显⽰qtdemux的的插件属于gstreamer1.0-plugins-good插件包三、gstreamer命令3.1 gst-inspect-1.0 查看插件信息命令gst-inspect-1.0 qtdemux 查看qtdemux插件的信息,如下所⽰:3.2 gst-launch-1.0 构建管道播放mp4⽂件命令:gst-launch-1.0 filesrc location=1.mp4 ! qtdemux ! decodebin ! videoconvert ! autovideosink播放mp4流程为:读⼊mp4⽂件->解mp4封装->解码->视频转换->播放,命令中的filesrc 、qtdemux、 decodebin 、videoconvert 、autovideosink插件分别对应这四个步骤,构建的管道如下图所⽰:产⽣⼀个指定宽⾼的视频gst-launch-1.0 videotestsrc ! video/x-raw,width=500,height=300 ! autovideosink。
gstreamer 编程

GStreamer 编程什么是 GStreamer?GStreamer 是一个开源的多媒体框架,用于构建流媒体应用程序和音视频处理工具。
它提供了一组库和插件,可以处理各种音频和视频格式,并支持实时流媒体。
GStreamer 的设计理念是模块化和可扩展的。
它由核心库和各种插件组成,可以根据需要选择加载不同的插件来支持特定的功能。
这使得 GStreamer 成为一个非常灵活和强大的多媒体框架。
GStreamer 的核心概念元素 (Elements)在 GStreamer 中,元素是构成多媒体处理管道的基本单元。
每个元素负责执行特定的任务,如读取文件、解码音视频数据、进行音视频处理等。
元素之间通过消息传递进行通信,并形成一个有向图结构。
GStreamer 提供了许多内置的元素,如filesrc(读取文件)、decodebin(解码器)和autovideosink(自动选择合适的视频输出设备)。
同时也可以自定义元素来满足特定需求。
流 (Pads)每个元素都有输入和输出端口,称为流端口 (pads)。
输入端口接收来自上游元素的数据流,输出端口将处理后的数据流传递给下游元素。
通过将不同元素的输入端口和输出端口连接起来,可以构建一个完整的媒体处理管道。
管道 (Pipeline)管道是多个元素连接在一起形成的数据处理链。
它定义了数据流的路径和处理顺序。
GStreamer 提供了一个GstPipeline类来创建和管理管道。
GStreamer 的编程接口GStreamer 提供了多种编程接口来开发应用程序,包括 C、C++、Python 和 Rust。
下面将以 C 语言为例介绍 GStreamer 的编程接口。
初始化 GStreamer在使用 GStreamer 之前,需要先初始化库并设置相关的环境变量。
以下是初始化GStreamer 的代码示例:#include <gst/gst.h>int main(int argc, char *argv[]) {// 初始化 GStreamergst_init(&argc, &argv);// 其他代码...return 0;}创建元素和管道要创建元素,可以使用gst_element_factory_make()函数,并指定要创建的元素类型和名称。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
一步一步创建GStreamer插件(ZZ)$git clonegit:///gstreamer/gst-template.git2、进入目录gst-template/gst-plugin/src$cdgst-template/gst-plugin/src$../tools/make_elementExampleFilter产生文件gstexamplefilter.c gstexamplefilter.h3、修改Makefile.am文件(注意:是src目录下的Makefile.am)$sudo geditMakefile.amplugin_LTLIBRARIES = libgstexamplefilter_la_SOURCES = gstexamplefilter.clibgstexamplefilter_la_CFLAGS = $(GST_CFLAGS)libgstexamplefilter_la_LIBADD = $(GST_LIBS)libgstexamplefilter_la_LDFLAGS =$(GST_PLUGIN_LDFLAGS)libgstexamplefilter_la_LIBTOOLFLAGS =--tag=disable-staticnoinst_HEADERS = gstexamplefilter.h总共有七行4、导入PKG_CONFIG_PATH环境变量,在命令行输入:$exportPKG_CONFIG_PATH=/usr/lib/pkgconfig5、进入目录gst-template/gst-plugin,修改文件autogen.sh进入上一层目录$cd..编辑autogen.sh文件:$sudo geditautogen.sh如果是通过CVS获取的模板,则修改原来的srcfile=src/main.c为新的:srcfile=src/gstexamplefilter.c如果是通过GIT获取的模板,则在autogen.sh的开始添加:srcfile=src/gstexamplefilter.c6、运行autogen.sh,产生Makefile 文件$./autogen.sh7、开始安装:$./configure$make$sudo makeinstall再进入src子目录中$cd src用ls -a查询会有.libs目录产生(注意:.libs 为隐藏目录)进入.libs$cd .libs$ls -a会发现里面产生了libgstexamplefilter.so8、将插件加入到gstreamer库中把libgstexamplefilter.so这两个文件拷贝到系统目录中:/usr/lib/gstreamer-0.10$sudo cp /usr/lib/gstreamer-0.10/$sudo cp libgstexamplefilter.so/usr/lib/gstreamer-0.10/libgstexamplefilter.so如果gstreamer无法扫描到新加入的plugin,可能是因为路径设置不正确(GST_PLUGIN_PATH环境变量)用gst-inspect命令来查看plugin时,会建立一个cache文件:如在X86上是$HOME/.gstreamer-0.10/registry.x86_64.bin如果有新的plugin加入,可能需要先删除这个cache文件,再重新运行gst-inspect,否则不会把新的plugin扫描到cache中。
几个重要的环境变量:1:GST_PLUGIN_SCANNERenv = g_getenv("GST_PLUGIN_SCANNER");//设置gst-plugin_scanner这个命令的路径 2.GST_PLUGIN_PATHplugin_path = g_getenv ("GST_PLUGIN_PATH");//plugin的搜索路径g_warning ("External plugin loader failed. Thismost likely means that ""the plugin loader helper binary was not found or could not be run.""%s", (g_getenv ("GST_PLUGIN_PATH") != NULL) ?"If you are running an uninstalled GStreamer setup, you might need""to update your gst-uninstalled script so that the ""GST_PLUGIN_SCANNER environment variable gets set." : "");3.GST_PLUGIN_SYSTEM_PATHGST_PLUGIN_SYSTEM_PATH specifies a list of plugins that are alwaysloaded by default. If not set, this defaults tothe system-installedpath,and the plugins installed in the user's home directoryplugin_path = g_getenv("GST_PLUGIN_SYSTEM_PATH"); 如果这个变量没有设置,default:plugin_path = g_getenv("GST_PLUGIN_SYSTEM_PATH");if (plugin_path == NULL){home_plugins= g_build_filename (g_get_home_dir (),".gstreamer-" GST_MAJORMINOR, "plugins", NULL);} 4. GST_REGISTRY_UPDATE(yes or no),是否重新扫描去更新cache内容update_env = g_getenv("GST_REGISTRY_UPDATE")do_update =(strcmp (update_env, "no") != 0) 函数调用:init_post()->gst_update_registry()->ensure_current_regist ry()->gst_registry_binary_read_cache->scan_and_update_registry()->读环境变量GST_PLUGIN_PATH->gst_registry_scan_path_internal()->读环境变量GST_PLUGIN_SYSTEM_PATH->gst_registry_scan_path_internal() (从目录下去读文件)检查插件:$gst-inspect examplefilter如果显示了插件的信息,那么插件就创建好了(2) Gst good/ugly/bad库中的plugin的列表/documentation/plugins.html关于whitelist和blacklist(黑名单)在plugin库中,有些plugin的license是blacklist的:if (strcmp (plugin->desc.license, "BLACKLIST") ==0)plugin->flags |= GST_PLUGIN_FLAG_BLACKLISTED; 但是BLACKLIST并不是开放给用户设置的,而是gstreamer 里面自己使用的。
含义是说如果这个plugin加载失败时,那么就加入到blacklist中,下次不需要去扫描了,用户也不能去使用。
这种plugin在scan时会进入blacklist的pluginlist中,在下次扫描时不会去扫描这些blacklist。
exchange_packets()->read_one()->handle_rx_packet(payloadLength)->plugin_loader_create_bl acklist_plugin()代码:if (entry != NULL) {plugin_loader_create_blacklist_plugin (l,entry);//plugin->desc.license = "BLACKLIST";l->got_plugin_details = TRUE;}如果要查看为什么加载plugin会失败:https:///show_bug.cgi?id=627102plugins are blacklisted when there's an error loading them. Youcancheck what went wrong by removing your registry(~/.gstreamer-0.10/registry*) and then running:GST_DEBUG=2,GST_PLUGIN_LOADING:5,GST_REGISTR Y:5gst-inspect-0.10上面这些参数是设置debug系统:_gst_debug_init()(3) Gstreamer中的几个命令使用/library/cmd/blcmdl1_gst-inspect.htm/man/man1/gst-inspect.html gst-inspect: gst-inspect prints information about available GStreamerplugins, information about a particular plugin, or information about a particular element.If no element or plugin argument is specified,gst-inspect prints a list of all plugins and elements. If an element or plugin argument is specified,gst-inspect prints information about that element orplug-in. If a given argument is valid as either an element or a plugin, gst-inspect treats the argument as an element, by default.OPTIONSThe following options are supported by gst-inspect:-a, --print-all Print all elements.--version Print GStreamer version number.gst-std-options Standard options available for use withmost GStreamer applications. See gst-std-options(5) for more information.OPERANDSThe following operands are supported:element Name of an element.plugin Name of a plugin.EXAMPLESExample 1: Displaying Information About a Plugin: example% gst-inspect alawPlugin Details:Name: alawDescription: ALaw audio conversion routines Filename: /usr/lib/gstreamer-0.10/libgstalaw.so Version: 0.10.3License: LGPLSource module: gst-plugins-goodBinary package: GStreamer Good Plug-ins source releaseOrigin URL: Unknown package origin alawdec: A Law audio decoderalawenc: A Law audio encoder 2 features:+-- 2 elementsgst-launch:gst-launch builds and runs basic GStreamer pipelines.In simple form, a pipeline-description is a list ofelements separated by exclamation marks (!). Properties can be appended to elements, in the form property=value.For a complete description of possible values forpipeline-description, see the section Pipeline Description below or consult the GStreamer documentation.Please note that gst-launch is primarily a debugging toolfor developers and users. You should not build applications on topof it. For applications, use the gst_parse_launch() function of the GStreamer API as an easy way to construct pipelines from pipelinedescriptions.OPTIONSThe following options are supported by gst-launch:-X,--exclude=type1,type2,... Do not outputstatus information of specified type.-f, --no-fault Do not install a faulthandler.-o, -output-=file Save XMLrepresentation of pipeline to file, then exit.-t, --tags Output tags, also known asmetadata.-T, --trace Print memory allocation trace,if enabled at compile time.-v, --verbose Output status information andproperty notifications.--version Print GStreamer version number.gst-std-options Standard options available for use withmost GStreamer applications. See gst-std-options(5) for more information.EXTENDED DESCRIPTIONPipelineDescriptionA pipeline consists elements and links. Elements can be put into bins of different sorts. Elements, links and bins can be specified in a pipeline description in any order.Elementselementtype [property1 ...]Creates an element of type elementtype and sets the properties.Propertiesproperty=value ...Sets the property to the specified value. You can usegst-inspect(1) to find out about properties and allowed values of different elements.Enumeration properties can be set by name, nick or value.Bins[bintype.] ( [property1 ...] pipeline-description )Specifies that a bin of type bintype is created and thegiven properties are set. Every element between the braces is put into the bin. Please note the dot that has to be used after the bintype. You will almost never need this functionality, itis only really useful for applications using thegst_launch_parse()API with ’bin’ as bintype. That way it is possible to build partial pipelines instead of a full-fledged top-level pipeline.Links[[srcelement].[pad1,...]] ! [[sinkelement].[pad1,...]] [[srcelement].[pad1,...]] ! caps ![[srcelement].[pad1,...]]Links the element with name srcelement to the elementwith name sinkelement, using the caps specified incaps as a filter. Names can be set on elements with the name property. If the name is omitted, the element that was specified directly in front of or after the link is used. This works across bins. If a padname is given, the link is done with these pads. If no pad names are given all possibilities are tried and a matching pad is used. If multiple padnames are given, both sides must havethe same number of pads specified and multiple links are done inthe given order. So the simplest link is a simple exclamation mark,that links the element to the left of it to the element right ofit.Capsmimetype [, property[, property ...]]] [; caps[; caps ...]]Creates a capability with the given mimetype and optionally withgiven properties. The mimetype can be escaped using " or ’. Ifyouwant to chain caps, you can add more caps in the same format afterwards.Propertiesname[:type]=valuein lists and ranges: [type=]valueSets the requested property in capabilities. The name is an alphanumeric value and the type can have the following case-insensitive values:o i or int for integer values or rangeso f or float for float values or rangeso 4 or fourcc for FOURCC valueso b, bool, or boolean for boolean valueso s, str, or string for stringso l or list for listsIf no type was given, the following order is tried: integer, float, boolean, string. Integer values must be parsable bystrtol(), floats by strtod(). FOURCC values may either be integersor strings. Boolean values are (case insensitive) yes, no, true or false and may like strings be escaped with " or ’.Ranges are in this format: [ property, property ]Lists use this format: ( property [, property ...] )PipelineControlA pipeline can be controlled by signals. SIGUSR2 will stop the pipeline (GST_STATE_NULL); SIGUSR1 will put it back to play(GST_STATE_PLAYING). By default, the pipeline will start in theplaying state. There are currently no signals defined to go into the ready or pause (GST_STATE_READY andGST_STATE_PAUSED) stateexpli- citely.EXAMPLESThe examples below assume that you have the correct plugins available. In general, "sunaudiosink" can be substituted with another audio output plugin such as "esdsink", "alsasink", "osxaudiosink", or "artsdsink". Likewise, "xvimagesink" can be substituted with "ximagesink", "sdlvideosink", "osxvideosink", or"aasink". Keep in mind though that different sinks might accept different formats and even the same sink might accept different formats on different machines, so you might need to add converterelements like audioconvert and audioresample (for audio) or ffmpegcolorspace (for video) in front of the sink to make things work.Example 1: Audio PlaybackPlay the WA V music file "music.wav":example% gst-launch filesrc location=music.wav ! wavparse ! sunaudiosinkPlay the mp3 music file "music.mp3":example% gst-launch filesrc location=music.mp3 ! flump3dec !Play the Ogg V orbis file "music.ogg":example% gst-launch filesrc location=music.ogg ! oggdemux ! vorbisdec ! audioconvert ! sunaudiosinkPlay an mp3 file or an http stream using GNOME-VFS: example% gst-launch gnomevfssrc location=music.mp3 ! flump3dec ! sunaudiosinkexample% gst-launch gnomevfssrclocation=/music.mp3 ! flump3dec ! sunaudiosinkUse GNOME-VFS to play an mp3 file located on an SMB server:example% gst-launch gnomevfssrclocation=smb://computer/music.mp3 ! flump3dec !Example 2: Video PlaybackPlay an Ogg video file:example% gst-launch filesrc location=video.ogg ! oggdemux ! theoradec ! ffmpegcolorspace ! xvimagesinkExample 3: Format ConversionConvert an mp3 music file to the Ogg V orbis format: example% gst-launch filesrc location=music.mp3 ! flump3dec ! audioconvert ! vorbisenc ! oggmux ! filesinklocation=music.oggConvert an mp3 music file to the FLAC format:example% gst-launch filesrc location=music.mp3 ! flump3dec ! audioconvert ! flacenc ! filesink location=test.flacConvert a .WA V file to the Ogg V orbis format:example% gst-launch filesrc location=music.wav ! wavparse ! audioconvert ! vorbisenc ! oggmux ! filesinklocation=music.oggExample 4: Recording AudioRecord sound from your audio input and encode it into an Ogg file:example% gst-launch sunaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=music.oggExample 5: Compact Disk (CDDA)Play track number 3 from compact disc:example% gst-launch cddasrc track=3 ! sunaudiosinkPlay track number 5 from compact disc:example% gst-launch cdda://5 ! sunaudiosinkExample 6: DiagnosticGenerate a null stream and ignore it:example% gst-launch fakesrc ! fakesinkGenerate a pure tone to test the audio output:example% gst-launch audiotestsrc ! sunaudiosinkGenerate a familiar test pattern to test the video output: example% gst-launch videotestsrc ! xvimagesinkGenerate a familiar test pattern to test the video output: example% gst-launch videotestsrc ! ximagesinkExample 7: Automatic LinkingYou can use the decodebin element to automatically select the right elements to get a working pipeline.Play any supported audio format:example% gst-launch filesrc location=musicfile ! decodebin ! sunaudiosinkPlay any supported video format with video and audio output. Threads are used automatically.example% gst-launch filesrc location=videofile ! decodebin name=decoder decoder. ! queue ! audioconvert ! audioresample ! osssink decoder. ! ffmpegcolorspace ! xvimagesinkTo make this even easier, you can use the playbin element: example% gst-launch playbin uri=file:///home/joe/foo.aviExample 8: Filtered ConnectionsThese examples show how to use filtered capabilities.Show a test image and use the YUY2 or YV12 video format for this:example% gst-launch videotestsrc !video/x-raw-yuv,format=urcc)YUY2;video/x-raw-yuv,format=u rcc)YV12 ! xvimagesinkRecord audio and write it to a .wav file. Force usage of signed 16 to 32 bit samples and a sample rate between 32kHz and64KHz:example% gst-launchsunaudiosrc ! ’audio/x-raw-int,rate=[32000,64000],width=[16,3 2],depth={16,24,32},signed=(boolean)true’! wavenc ! filesink location=recording.wav更加详细的信息查看:/documentation/。