Summary
GStreamer provides different command-line tool for quickly viewing information and verify that the Pipeline to run correctly, in the usual development process, we also use the GStreamer priority command-line tool to verify, and then Pipeline integrated into an application. This article describes the use of gst-inspect-1.0, gst-discoverer-1.0, gst-launch-1.0 command-line tool.
gst-inspect-1.0
This command has three modes of operation, in practice we often use the first and third way:
First, without any parameters. A list of all Element current system of support, these Element can be used to construct the Pipeline.
Second, with the file name. This will specify the file as a GStreamer plug-in, try to list Element contained therein. The following example command lists two Elements libgstjpeg.so contains:
$ gst-inspect-1.0 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstjpeg.so Plugin Details: Name jpeg Description JPeg plugin library Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstjpeg.so Version 1.8.3 License LGPL Source module gst-plugins-good Source release date 2016-08-19 Binary package GStreamer Good Plugins (Ubuntu) Origin URL https://launchpad.net/distros/ubuntu/+source/gst-plugins-good1.0 jpegenc: JPEG image encoder jpegdec: JPEG image decoder 2 features: +-- 2 elements
Third, with the Element names. Details Element will be listed. For example, the following command lists jpeg decoder input data types supported, Pad information supported attributes and values. Our main concern Pad Template, and attribute information of Element.
$ gst-inspect-1.0 jpegdec Factory Details: Rank primary (256) Long-name JPEG image decoder Klass Codec/Decoder/Image Description Decode images from JPEG format Author Wim Taymans <[email protected]> Plugin Details: Name jpeg Description JPeg plugin library Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstjpeg.so Version 1.8.3 License LGPL Source module gst-plugins-good Source release date 2016-08-19 Binary package GStreamer Good Plugins (Ubuntu) Origin URL https://launchpad.net/distros/ubuntu/+source/gst-plugins-good1.0 GObject +----GInitiallyUnowned +----GstObject +----GstElement +----GstVideoDecoder +----GstJpegDec Pad Templates: SINK template: 'sink' Availability: Always Capabilities: image/jpeg SRC template: 'src' Availability: Always Capabilities: video/x-raw format: { I420, RGB, BGR, RGBx, xRGB, BGRx, xBGR, GRAY8 } width: [ 1, 2147483647 ] height: [ 1, 2147483647 ] framerate: [ 0/1, 2147483647/1 ] Element Flags: no flags set Element Implementation: Has change_state() function: gst_video_decoder_change_state Element has no clocking capabilities. Element has no indexing capabilities. Element has no URI handling capabilities. Pads: SINK: 'sink' Implementation: Has chainfunc(): gst_video_decoder_chain Has custom eventfunc(): gst_video_decoder_sink_event Has custom queryfunc(): gst_video_decoder_sink_query Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default Pad Template: 'sink' SRC: 'src' Implementation: Has custom eventfunc(): gst_video_decoder_src_event Has custom queryfunc(): gst_video_decoder_src_query Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default Pad Template: 'src' Element Properties: name : The name of the object flags: readable, writable String. Default: "jpegdec0" parent : The parent of the object flags: readable, writable Object of type "GstObject" idct-method : The IDCT algorithm to use flags: readable, writable Enum "GstIDCTMethod" Default: 1, "ifast" (0): islow - Slow but accurate integer algorithm (1): ifast - Faster, less accurate integer method (2): float - Floating-point: accurate, fast on fast HW max-errors : (Deprecated) Error out after receiving N consecutive decoding errors (-1 = never fail, 0 = automatic, 1 = fail on first error) flags: readable, writable, 0x80000000 Integer. Range: -1 - 2147483647 Default: 0
gst-discoverer-1.0
This command GStreamer based tutorial 06-- get media information used before, is GstDiscoverer package interface, you can easily view media files coded, frame rate and other information.
$ gst-discoverer-1.0 sintel_trailer-480p.mp4 Analyzing file:///home/xleng/video/sintel_trailer-480p.mp4 Done discovering file:///home/xleng/video/sintel_trailer-480p.mp4 Topology: container: Quicktime audio: MPEG-4 AAC video: H.264 (High Profile) Properties: Duration: 0:00:52.209000000 Seekable: yes Live: no Tags: audio codec: MPEG-4 AAC audio maximum bitrate: 128000 datetime: 1970-01-01T00:00:00Z title: Sintel Trailer artist: Durian Open Movie Team copyright: (c) copyright Blender Foundation | durian.blender.org description: Trailer for the Sintel open movie project encoder: Lavf52.62.0 container format: ISO MP4/M4A video codec: H.264 / AVC bitrate: 535929
gst-launch-1.0
gst-launch we usually use up a command, it receives a character string described by way Pipline, be instantiated and run. We can use this command to quickly check whether each element Pipeline correctly connected. When we need to build the Pipeline is complex, we can split the Pipeline, Pipeline progressively verify the legitimacy by gst-launch.
By gst-launch validation string Pipeline can be used directly gst_parse_launch () interface to convert it into GstPipeline objects, saving us call the API to create a separate Element of time.
When we use a string describing the Pipeline, need to pass between each Element exclamation mark "!" Separated Element, so gst-launch can be correctly identified.
When using gst-launch, according to different application scenarios, we can be divided into the following types.
The default parameter creates Pipeline
In this way we simply Element exclamation mark is used to separate, for example:
$ gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
Set the properties of the Element
In some cases, we need to modify the properties of the Element, or specify the desired parameters (such as playbin the uri parameter), Element of properties directly follows the Element. The following command will set videotestsrc video mode, the output image is annular. Property Supported values can be viewed by gst-inspect command.
$ gst-launch-1.0 videotestsrc pattern=11 ! videoconvert ! autovideosink
If the attribute value contained spaces, and can be placed in a single or double quotes.
$ gst-launch-1.0 -v videotestsrc ! clockoverlay halignment=right valignment=bottom text="Edge City" shaded-background=true font-desc="Sans, 36" ! videoconvert ! autovideosink
It contains Pipeline branch
Each Element has a name property, we can use the name to implement complex Pipeline contain multiple branches, which is common in multiple output / input Element (mux, demux, tee, etc.).
The following command creates two tee branch, respectively, for different sink, in a branch of the Pipeline is completed (arrival sink), we can use the "name plus a point" to re-create a branch.
$ gst-launch-1.0 videotestsrc ! videoconvert ! tee name=t ! queue ! autovideosink t. ! queue ! autovideosink
The same way, we can also multiple branches into one. The following command first decode the file, the video is encoded as H.264, audio encoding to MP3, and eventually merge to generate TS files. Note the use of dmux and mux Element.
$ gst-launch-1.0 filesrc location=surround.mp4 ! decodebin name=dmux ! queue ! audioconvert ! lamemp3enc ! mux. \
dmux. ! queue ! x264enc ! mpegtsmux name=mux ! queue ! filesink location=out.ts
Element of designated Pad
In some cases, we want to specify a Pad is used to connect, we can specify a named Element of Pad to achieve.
$ gst-launch-1.0 souphttpsrc location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! \
matroskademux name=d d.video_00 ! matroskamux ! filesink location=sintel_video.mkv
The above command will sintel_trailer-480p.webm the Demux file, select only one of the video (video_00), which is then retained as mk document, retaining only the video part. If you want to retain only the audio portion, you can use the following command:
$ gst-launch-1.0 souphttpsrc location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! \
matroskademux name=d d.audio_00 ! vorbisparse ! matroskamux ! filesink location=sintel_audio.mka
None of the above two commands to decode the video, just copyed from one vessel to another vessel.
Caps Filter stream using filter
When Pad Element comprises a plurality of outputs, may cause the connection to the next Pad Element is uncertain. Element Element support the next output of all types, then randomly selects a GStreamer Pad for connection.
For example: we can not determine the following Pipeline will use video_00 or audio_00 connected to filesink, because filesink supports both audio and video input.
$ gst-launch-1.0 souphttpsrc location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! matroskademux ! filesink location=test
As we mentioned one, explicitly specified connection with Pad, or use Caps Filter:
$ gst-launch-1.0 souphttpsrc location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! \
matroskademux ! video/x-vp8 ! matroskamux ! filesink location=sintel_video.mkv
Caps Filter receiver performance of a specified data type only Element, and passes the data to the next Element, can efficiently solve the problem of ambiguity.
We can use gst-inspect to see the output Pad Element to decide what our Caps Filter parameters need to be added. After gst-launch plus Pad -v output parameter information used in connection Pipeline.
For more filters, we need separated by commas.
For some special types of parameters, GStreamer provided to convert the keyword:
- or int i represents an integer or range;
- f represents a float or float and range;
- 4 represents fourcc FOURCC or 4 character codes;
- b, bool, or boolean represent Boolean data;
- s, str, string, or a string representing;
- fraction expressed as a fraction (e.g., frame rate, pixel aspect ratio);
- l or a list representing the list.
UDP RTP for transmitting and receiving data:
$ gst-launch-1.0 v4l2src ! \ video/x-raw-yuv,width=128,height=96,format='(fourcc)'UYVY ! \ videoconvert ! ffenc_h263 ! video/x-h263 ! rtph263ppay pt=96 ! \ udpsink host=192.168.1.1 port=5000 sync=false $gst-launch-1.0 udpsrc port=5000 ! application/x-rtp, \ clock-rate=90000,payload=96 ! rtph263pdepay queue-delay=0 ! ffdec_h263 \ ! xvimagesink
YUY2 YV12 use as a test or video format, frame rate of 30 frames / sec:
$ gst-launch-1.0 videotestsrc ! \ 'video/x-raw-yuv,format=(fourcc)YUY2,framerate=30/1;video/x-raw-yuv,format=(fourcc)YV12,framerate=30/1' \ ! xvimagesink
By alsasrc recordings, limited sampling rate and bit width:
$ gst-launch-1.0 alsasrc! \ 'audio/x-raw-int,rate=[32000,64000],width=[16,32],depth={16,24,32},signed=(boolean)true' \ ! wavenc ! filesink location=recording.wav
to sum up
In this article, we have mastered:
- How to view detailed information on each widget and GStreamer plug-ins and the current system owned by gst-inspect-1.0.
- How to View Metadata media files by gst-discoverer-1.0.
- How gst-launch-1.0 and run tests Pipeline.
- If you specify a data filter through Caps Filter.
Quote
https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c
https://gstreamer.freedesktop.org/documentation/tutorials/basic/gstreamer-tools.html?gi-language=c