From 3efae9fab09e367b65d23d5a47dce94dfaacdd41 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 10 Dec 2004 17:19:56 +0000 Subject: [PATCH] Added more gst-launch examples Original commit message from CVS: Added more gst-launch examples --- ChangeLog | 5 + docs/manual/appendix-programs.xml | 316 ------------------------------ docs/manual/programs.xml | 19 +- 3 files changed, 23 insertions(+), 317 deletions(-) delete mode 100644 docs/manual/appendix-programs.xml diff --git a/ChangeLog b/ChangeLog index 1b7f7faf4f..006f697d17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-12-10 Stefan Kost + + * docs/manual/programs.xml: + Added more gst-launch examples. + 2004-12-09 Ronald S. Bultje * gst/gstqueue.c: (gst_queue_handle_src_query): diff --git a/docs/manual/appendix-programs.xml b/docs/manual/appendix-programs.xml deleted file mode 100644 index 132a67da97..0000000000 --- a/docs/manual/appendix-programs.xml +++ /dev/null @@ -1,316 +0,0 @@ - - Programs - - - - - <command>gst-register</command> - - gst-register is used to rebuild the database of plugins. - It is used after a new plugin has been added to the system. The plugin database - can be found, by default, in /etc/gstreamer/reg.xml. - - - - - <command>gst-launch</command> - - This is a tool that will construct pipelines based on a command-line - syntax. - - - A simple commandline to play a mp3 audio file looks like: - - -gst-launch filesrc location=hello.mp3 ! mad ! osssink - - - A more complex pipeline looks like: - - -gst-launch filesrc location=redpill.vob ! mpegdemux name=demux \ - demux.audio_00! { ac3parse ! a52dec ! osssink } \ - demux.video_00! { mpeg2dec ! xvideosink } - - - lists more gst-launch commandlines. - - - - You can also use the parser in you own - code. GStreamer 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: - - -#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; -} - - - Note how we can retrieve the filesrc element from the constructed bin using the - element name. - - - Grammar Reference - - The gst-launch 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. - - - Elements - - ... mad ... - - - 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. - - - - Links - - ... !sink ... - - - 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 - my_element_name.sink_pad. - - - - Properties - - ... location="http://gstreamer.net" ... - - - 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 - (\). 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. - - - - Bins, Threads, and Pipelines - - ( ... ) - - - A pipeline description between parentheses is placed into a bin. The open paren may be - preceded by a type name, as in jackbin.( ... ) 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. - - - - - More Examples - - This chapter collects some more complex pipelines. The examples are split into several lines, - so make sure to include the trailing backslashes. - - - Play a remote mp3 audio file: - -gst-launch gnomevfssrc location=http://www.server.org/hello.mp3 ! mad ! alsasink - - - - Play a local mp3 audio file with visualisation: - -gst-launch filesrc location=Hello.mp3 ! mad ! tee name=t ! \ - { queue ! osssink } \ - { t. ! queue ! synaesthesia ! ffmpegcolorspace ! xvimagesink } - - - - Play a local ogg audio file: - -gst-launch filesrc location=file.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioscale ! alsasink - - - - Play a local ogg video file: - -gst-launch filesrc location=file.ogg ! oggdemux name=demux \ - { demux. ! queue ! theoradec ! ffmpegcolorspace ! videoscale ! xvimagesink } \ - { demux. ! queue ! vorbisdec ! audioconvert ! audioscale ! alsasink } - - - - Play a local avi video file: - -gst-launch filesrc location=video.avi ! mpegdemux name=demux \ - demux.audio_00! { queue ! ac3parse ! a52dec ! osssink } \ - demux.video_00! { queue ! mpeg2dec ! xvideosink } - - - - Transcoding an audio file from one format into another: - -gst-launch filesrc location=file.ogg ! oggdemux ! vorbisdec ! audioconvert ! flacenc ! filesink location=file.flac - - - - Transcoding an dvd video into a ogg video: - -gst-launch-0.8 oggmux name=mux ! filesink location=/tmp/file.ogg \ - { dvdreadsrc location=/dev/cdrom ! dvddemux name=demux.audio_00 ! \ - { queue ! a52dec ! audioconvert ! rawvorbisenc ! queue ! mux. } \ - { demux.video_00 ! queue ! mpeg2dec ! ffcolorspace ! videoscale ! video/x-raw-yuv,width=384,height=288 ! tee name=t ! \ - { queue ! theoraenc ! queue ! mux. } \ - } \ - } \ - { t. ! queue ! ffcolorspace ! ximagesink } - - - - - - - - <command>gst-inspect</command> - - This is a tool to query a plugin or an element about its properties. - - - To query the information about the element mad, you would specify: - - - -gst-inspect mad - - - - Below is the output of a query for the osssink element: - - - -Factory Details: - Long name: Audio Sink (OSS) - Class: Sink/Audio - Description: Output to a sound card via OSS - Version: 0.3.3.1 - Author(s): Erik Walthinsen <omega@cse.ogi.edu>, Wim Taymans <wim.taymans@chello.be> - Copyright: (C) 1999 - -GObject - +----GstObject - +----GstElement - +----GstOssSink - -Pad Templates: - SINK template: 'sink' - Availability: Always - Capabilities: - 'osssink_sink': - MIME type: 'audio/raw': - format: String: int - endianness: Integer: 1234 - width: List: - Integer: 8 - Integer: 16 - depth: List: - Integer: 8 - Integer: 16 - channels: Integer range: 1 - 2 - law: Integer: 0 - signed: List: - Boolean: FALSE - Boolean: TRUE - rate: Integer range: 1000 - 48000 - - -Element Flags: - GST_ELEMENT_THREADSUGGESTED - -Element Implementation: - No loopfunc(), must be chain-based or not configured yet - Has change_state() function: gst_osssink_change_state - Has custom save_thyself() function: gst_element_save_thyself - Has custom restore_thyself() function: gst_element_restore_thyself - -Clocking Interaction: - element requires a clock - element provides a clock: GstOssClock - -Pads: - SINK: 'sink' - Implementation: - Has chainfunc(): 0x40056fc0 - Pad Template: 'sink' - -Element Arguments: - name : String (Default "element") - device : String (Default "/dev/dsp") - mute : Boolean (Default false) - format : Integer (Default 16) - channels : Enum "GstAudiosinkChannels" (default 1) - (0): Silence - (1): Mono - (2): Stereo - frequency : Integer (Default 11025) - fragment : Integer (Default 6) - buffer-size : Integer (Default 4096) - -Element Signals: - "handoff" : void user_function (GstOssSink* object, - gpointer user_data); - - - - To query the information about a plugin, you would do: - - - -gst-inspect gstelements - - - - diff --git a/docs/manual/programs.xml b/docs/manual/programs.xml index 132a67da97..a1b2e5f996 100644 --- a/docs/manual/programs.xml +++ b/docs/manual/programs.xml @@ -134,6 +134,10 @@ main (int argc, char *argv[]) the g_value_convert routines. No error message will be displayed on an invalid conversion, due to limitations in the value convert API. + + The list of properties an element supports can be found out using + gst-inspect elemnt-name. + Bins, Threads, and Pipelines @@ -143,7 +147,7 @@ main (int argc, char *argv[]) A pipeline description between parentheses is placed into a bin. The open paren may be preceded by a type name, as in jackbin.( ... ) to make - a bin of a specified type. Square brackets make pipelines, and curly braces 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. @@ -154,6 +158,16 @@ main (int argc, char *argv[]) This chapter collects some more complex pipelines. The examples are split into several lines, so make sure to include the trailing backslashes. + When modifying the pipelines and seeking for the right element to insert, a grep of the gst-inspect + output often gives a starting point: + +gst-inspect | grep "avi" + + Another way is to do: + +gst-launch filesrc location=video.avi ! decodebin name=d ! xvimagesink d. ! { queue ! alsasink } -v + + and look on the output, which plugins it chooses. Play a remote mp3 audio file: @@ -195,6 +209,9 @@ gst-launch filesrc location=video.avi ! mpegdemux name=demux \ Transcoding an audio file from one format into another: gst-launch filesrc location=file.ogg ! oggdemux ! vorbisdec ! audioconvert ! flacenc ! filesink location=file.flac + + +gst-launch filesrc location=file.mp3 ! id3demus ! mad ! audioconvert ! rawvorbisenc ! oggmux ! filesink location=file.ogg