1 <chapter id="chapter-programs">
2 <title>Programs</title>
6 <sect1 id="section-programs-gst-register">
7 <title><command>gst-register</command></title>
9 <command>gst-register</command> is used to rebuild the database of plugins.
10 It is used after a new plugin has been added to the system. The plugin database
11 can be found, by default, in <filename>/etc/gstreamer/reg.xml</filename>.
15 <sect1 id="section-programs-gst-launch">
16 <title><command>gst-launch</command></title>
18 This is a tool that will construct pipelines based on a command-line
22 A simple commandline to play a mp3 audio file looks like:
25 gst-launch filesrc location=hello.mp3 ! mad ! osssink
28 A more complex pipeline looks like:
31 gst-launch filesrc location=redpill.vob ! mpegdemux name=demux \
32 demux.audio_00! { ac3parse ! a52dec ! osssink } \
33 demux.video_00! { mpeg2dec ! xvideosink }
36 <xref linkend="section-programs-gst-launch-more-examples"/> lists more gst-launch commandlines.
40 You can also use the parser in you own
41 code. <application>GStreamer</application> provides a function
42 gst_parse_launch () that you can use to construct a pipeline.
43 The following program lets you create an MP3 pipeline using the
44 gst_parse_launch () function:
47 #include <gst/gst.h>
50 main (int argc, char *argv[])
56 gst_init (&argc, &argv);
59 g_print ("usage: %s <filename>\n", argv[0]);
63 pipeline = gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
65 g_print ("Parse error: %s\n", error->message);
69 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc");
70 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
72 gst_element_set_state (pipeline, GST_STATE_PLAYING);
74 while (gst_bin_iterate (GST_BIN (pipeline)));
76 gst_element_set_state (pipeline, GST_STATE_NULL);
82 Note how we can retrieve the filesrc element from the constructed bin using the
86 <title>Grammar Reference</title>
88 The <command>gst-launch</command> syntax is processed by a flex/bison parser. This section
89 is intended to provide a full specification of the grammar; any deviations from this
90 specification is considered a bug.
93 <title>Elements</title>
98 A bare identifier (a string beginning with a letter and containing
99 only letters, numbers, dashes, underscores, percent signs, or colons)
100 will create an element from a given element factory. In this example,
101 an instance of the "mad" MP3 decoding plugin will be created.
110 An exclamation point, optionally having a qualified pad name (an the name of the pad,
111 optionally preceded by the name of the element) on both sides, will link two pads. If
112 the source pad is not specified, a source pad from the immediately preceding element
113 will be automatically chosen. If the sink pad is not specified, a sink pad from the next
114 element to be constructed will be chosen. An attempt will be made to find compatible
115 pads. Pad names may be preceded by an element name, as in
116 <computeroutput>my_element_name.sink_pad</computeroutput>.
120 <title>Properties</title>
122 ... location="http://gstreamer.net" ...
125 The name of a property, optionally qualified with an element name, and a value,
126 separated by an equals sign, will set a property on an element. If the element is not
127 specified, the previous element is assumed. Strings can optionally be enclosed in
128 quotation marks. Characters in strings may be escaped with the backtick
129 (<literal>\</literal>). If the right-hand side is all digits, it is considered to be an
130 integer. If it is all digits and a decimal point, it is a double. If it is "true",
131 "false", "TRUE", or "FALSE" it is considered to be boolean. Otherwise, it is parsed as a
132 string. The type of the property is determined later on in the parsing, and the value is
133 converted to the target type. This conversion is not guaranteed to work, it relies on
134 the g_value_convert routines. No error message will be displayed on an invalid
135 conversion, due to limitations in the value convert API.
138 The list of properties an element supports can be found out using
139 <userinput>gst-inspect elemnt-name</userinput>.
143 <title>Bins, Threads, and Pipelines</title>
148 A pipeline description between parentheses is placed into a bin. The open paren may be
149 preceded by a type name, as in <computeroutput>jackbin.( ... )</computeroutput> to make
150 a bin of a specified type. Square brackets '[ ]' make pipelines, and curly braces '{ }' make
151 threads. The default toplevel bin type is a pipeline, although putting the whole
152 description within parentheses or braces can override this default.
156 <sect2 id="section-programs-gst-launch-more-examples">
157 <title>More Examples</title>
159 This chapter collects some more complex pipelines. The examples are split into several lines,
160 so make sure to include the trailing backslashes.
161 When modifying the pipelines and seeking for the right element to insert, a grep of the gst-inspect
162 output often gives a starting point:
164 gst-inspect | grep "avi"
166 Another way is to do:
168 gst-launch filesrc location=video.avi ! decodebin name=d ! xvimagesink d. ! { queue ! alsasink } -v
170 and look on the output, which plugins it chooses.
173 Play a remote mp3 audio file:
175 gst-launch gnomevfssrc location=http://www.server.org/hello.mp3 ! mad ! alsasink
179 Play a local mp3 audio file with visualisation:
181 gst-launch filesrc location=Hello.mp3 ! mad ! tee name=t ! \
182 { queue ! osssink } \
183 { t. ! queue ! synaesthesia ! ffmpegcolorspace ! xvimagesink }
187 Play a local ogg audio file:
189 gst-launch filesrc location=file.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioscale ! alsasink
193 Play a local ogg video file:
195 gst-launch filesrc location=file.ogg ! oggdemux name=demux \
196 { demux. ! queue ! theoradec ! ffmpegcolorspace ! videoscale ! xvimagesink } \
197 { demux. ! queue ! vorbisdec ! audioconvert ! audioscale ! alsasink }
201 Play a local avi video file:
203 gst-launch filesrc location=video.avi ! mpegdemux name=demux \
204 demux.audio_00! { queue ! ac3parse ! a52dec ! osssink } \
205 demux.video_00! { queue ! mpeg2dec ! xvideosink }
209 Transcoding an audio file from one format into another:
211 gst-launch filesrc location=file.ogg ! oggdemux ! vorbisdec ! audioconvert ! flacenc ! filesink location=file.flac
214 gst-launch filesrc location=file.mp3 ! id3demus ! mad ! audioconvert ! rawvorbisenc ! oggmux ! filesink location=file.ogg
218 Transcoding an dvd video into a ogg video:
220 gst-launch-0.8 oggmux name=mux ! filesink location=/tmp/file.ogg \
221 { dvdreadsrc location=/dev/cdrom ! dvddemux name=demux.audio_00 ! \
222 { queue ! a52dec ! audioconvert ! rawvorbisenc ! queue ! mux. } \
223 { demux.video_00 ! queue ! mpeg2dec ! ffcolorspace ! videoscale ! video/x-raw-yuv,width=384,height=288 ! tee name=t ! \
224 { queue ! theoraenc ! queue ! mux. } \
227 { t. ! queue ! ffcolorspace ! ximagesink }
234 <sect1 id="section-programs-gst-inspect">
235 <title><command>gst-inspect</command></title>
237 This is a tool to query a plugin or an element about its properties.
240 To query the information about the element mad, you would specify:
248 Below is the output of a query for the osssink element:
253 Long name: Audio Sink (OSS)
255 Description: Output to a sound card via OSS
257 Author(s): Erik Walthinsen <omega@cse.ogi.edu>, Wim Taymans <wim.taymans@chello.be>
266 SINK template: 'sink'
270 MIME type: 'audio/raw':
272 endianness: Integer: 1234
279 channels: Integer range: 1 - 2
284 rate: Integer range: 1000 - 48000
288 GST_ELEMENT_THREADSUGGESTED
290 Element Implementation:
291 No loopfunc(), must be chain-based or not configured yet
292 Has change_state() function: gst_osssink_change_state
293 Has custom save_thyself() function: gst_element_save_thyself
294 Has custom restore_thyself() function: gst_element_restore_thyself
296 Clocking Interaction:
297 element requires a clock
298 element provides a clock: GstOssClock
303 Has chainfunc(): 0x40056fc0
307 name : String (Default "element")
308 device : String (Default "/dev/dsp")
309 mute : Boolean (Default false)
310 format : Integer (Default 16)
311 channels : Enum "GstAudiosinkChannels" (default 1)
315 frequency : Integer (Default 11025)
316 fragment : Integer (Default 6)
317 buffer-size : Integer (Default 4096)
320 "handoff" : void user_function (GstOssSink* object,
325 To query the information about a plugin, you would do:
329 gst-inspect gstelements