<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >gst-launch</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="GStreamer Application Development Manual" HREF="index.html"><LINK REL="UP" TITLE="Programs" HREF="chapter-programs.html"><LINK REL="PREVIOUS" TITLE="Programs" HREF="chapter-programs.html"><LINK REL="NEXT" TITLE="gst-inspect" HREF="section-programs-gst-inspect.html"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="application" >GStreamer</SPAN > Application Development Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="chapter-programs.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 33. Programs</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="section-programs-gst-inspect.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="section-programs-gst-launch" >33.2. <B CLASS="command" >gst-launch</B ></A ></H1 ><P > This is a tool that will construct pipelines based on a command-line syntax. </P ><P > A simple commandline looks like: <PRE CLASS="screen" > gst-launch filesrc location=hello.mp3 ! mad ! osssink </PRE > A more complex pipeline looks like: <PRE CLASS="screen" > gst-launch filesrc location=redpill.vob ! mpegdemux name=demux \ demux.audio_00! { ac3parse ! a52dec ! osssink } \ demux.video_00! { mpeg2dec ! xvideosink } </PRE > </P ><P > You can also use the parser in you own code. <SPAN CLASS="application" >GStreamer</SPAN > provides a function gst_parse_launch () that you can use to construct a pipeline. The following program lets you create an MP3 pipeline using the gst_parse_launch () function: </P ><PRE CLASS="programlisting" > #include <gst/gst.h> int main (int argc, char *argv[]) { GstElement *pipeline; GstElement *filesrc; GError *error = NULL; gst_init (&argc, &argv); if (argc != 2) { g_print ("usage: %s <filename>\n", argv[0]); return -1; } pipeline = gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error); if (!pipeline) { g_print ("Parse error: %s\n", error->message); exit (1); } filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc"); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); gst_element_set_state (pipeline, GST_STATE_NULL); return 0; } </PRE ><P > Note how we can retrieve the filesrc element from the constructed bin using the element name. </P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="AEN1210" >33.2.1. Grammar Reference</A ></H2 ><P > The <B CLASS="command" >gst-launch</B > syntax is processed by a flex/bison parser. This section is intended to provide a full specification of the grammar; any deviations from this specification is considered a bug. </P ><DIV CLASS="sect3" ><H3 CLASS="sect3" ><A NAME="AEN1214" >33.2.1.1. Elements</A ></H3 ><PRE CLASS="screen" > ... mad ... </PRE ><P > A bare identifier (a string beginning with a letter and containing only letters, numbers, dashes, underscores, percent signs, or colons) will create an element from a given element factory. In this example, an instance of the "mad" MP3 decoding plugin will be created. </P ></DIV ><DIV CLASS="sect3" ><H3 CLASS="sect3" ><A NAME="AEN1218" >33.2.1.2. Links</A ></H3 ><PRE CLASS="screen" > ... !sink ... </PRE ><P > An exclamation point, optionally having a qualified pad name (an the name of the pad, optionally preceded by the name of the element) on both sides, will link two pads. If the source pad is not specified, a source pad from the immediately preceding element will be automatically chosen. If the sink pad is not specified, a sink pad from the next element to be constructed will be chosen. An attempt will be made to find compatible pads. Pad names may be preceded by an element name, as in <SAMP CLASS="computeroutput" >my_element_name.sink_pad</SAMP >. </P ></DIV ><DIV CLASS="sect3" ><H3 CLASS="sect3" ><A NAME="AEN1223" >33.2.1.3. Properties</A ></H3 ><PRE CLASS="screen" > ... location="http://gstreamer.net" ... </PRE ><P > The name of a property, optionally qualified with an element name, and a value, separated by an equals sign, will set a property on an element. If the element is not specified, the previous element is assumed. Strings can optionally be enclosed in quotation marks. Characters in strings may be escaped with the backtick (<VAR CLASS="literal" >\</VAR >). If the right-hand side is all digits, it is considered to be an integer. If it is all digits and a decimal point, it is a double. If it is "true", "false", "TRUE", or "FALSE" it is considered to be boolean. Otherwise, it is parsed as a string. The type of the property is determined later on in the parsing, and the value is converted to the target type. This conversion is not guaranteed to work, it relies on the g_value_convert routines. No error message will be displayed on an invalid conversion, due to limitations in the value convert API. </P ></DIV ><DIV CLASS="sect3" ><H3 CLASS="sect3" ><A NAME="AEN1228" >33.2.1.4. Bins, Threads, and Pipelines</A ></H3 ><PRE CLASS="screen" > ( ... ) </PRE ><P > A pipeline description between parentheses is placed into a bin. The open paren may be preceded by a type name, as in <SAMP CLASS="computeroutput" >jackbin.( ... )</SAMP > to make a bin of a specified type. Square brackets make pipelines, and curly braces make threads. The default toplevel bin type is a pipeline, although putting the whole description within parentheses or braces can override this default. </P ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="chapter-programs.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="section-programs-gst-inspect.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Programs</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="chapter-programs.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><B CLASS="command" >gst-inspect</B ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >