GStreamer:GstLaunch
lastmod 2024-10-31created 2023-01-209 edits
Examples
Gstreamer is made up of a pipe and filer (also called pad) structure, and these are connected to each other with !.
Basic
The element that outputs video is called a Sink, and AutoVideoSink automatically selects the system's default Sink. Let's simply display a screen like a test pattern.
Let's add a few Capabilities to this.
Connecting a webcam
Stream encoding
To send a stream over the network, it has to be compressed. Compression can be handled relatively simply by connecting a Pipe.
- mjpeg:
! jpegenc - VP8:
! vp8enc - Mpeg2:
! avenc_mpeg4
can be connected like this.
Stream payload
Payloading is the work of packing raw or compressed data into a network protocol. GDP (Gstreamer Data Protocol) or RTP (Real Time Protocol) is usually used. The Payload pad is piped after the Encoder pad in the following form.
-
! jpegenc ! rtpjpegpay - or
! vp8enc ! rtpv8pay - or
! avenc_mpeg4 ! rtpmp4vpay
Sending a stream
$ gst-launch-1.0 -v v4l2src device=/dev/video6 ! video/x-raw, width=640, height=480 ! videoconvert ! jpegenc ! rtpjpegpay ! udpsink host=10.90.1.50 port=5000
Here the updsink host address is the IP address of the Receiver to send to.
Receiving a stream
$ gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink
textoverlay
Output with pango-markup
gst-launch-1.0 videotestsrc ! textoverlay name=text_sink text='<span foreground="blue" size="x-large">Blue text</span> is <i>cool</i>!' ! videoconvert ! autovideosink
Branching a stream with Tee
gst-launch-1.0 \
videotestsrc ! video/x-raw,width=320,height=240 ! \
timeoverlay halignment=center valignment=center font-desc="Sans, 32" ! \
tee name=t \
t. ! queue ! autovideosink \
t. ! queue ! theoraenc bitrate=256 ! oggmux ! filesink location=test.ogg
Code used in answerjet-relay:
gst-launch-1.0 videotestsrc is-live=true ! textoverlay text="1" ! videorate silent=true ! "video/x-raw,framerate=1/2" ! tee name=t t. ! answerjet_relay t. ! autovideosink
See also
- GStreamer
- GStreamer:Basic
- GStreamer:GstLaunch - gst-launch-1.0 command line.
- GStreamer:GstInspect - gst-inspect-1.0 command line.
- GStreamer:Python
- GStreamer:C
Favorite site
- gst-launch-1.0
- (Gstreamer) Gstreamer basics
- Gstreamer command summary
- Using GStreamer (1) - Pipeline components and concepts | Devlog