Play with GStreamer Plugin

By combine the plugin in simple way you can make useful application

Game 1: Streaming video from webcam to server on show on screen

Streamer — sender side:

gst-launch-1.0 -v v4l2src device=/dev/video0  \
! "image/jpeg,width=1280, height=720,framerate=30/1" \
! rtpjpegpay \
! udpsink host=192.168.0.30 port=5000

Explanation:

It takes source picture (v4l2src) from device=/dev/video0 as image, format its size and sending frame rate, encode JPEG pictures into RTP packet (rtpjpegpay) and send for configured udp sink host (udpsink).

Server — receiver side:

gst-launch-1.0 -e -v udpsrc port=5000 ! \
application/x-rtp, encoding-name=JPEG,payload=26 ! \
rtpjpegdepay ! jpegdec ! \
autovideosink

Explanation:

It create RPT servers on port 5000, decode jpeg picture (jpegdec) and use autovideosink to show the received picture.

Game 2: Stream “screencast” and webcam as 
picture in picture”

gst-launch-1.0 -e ximagesrc use-damage=0 endx=1024 endy=600\
! video/x-raw,framerate=30/1\
! queue\
! mix. \
v4l2src\
! video/x-raw,width=320,height=240\
! queue \
! videomixer name=mix\
! videoconvert\
! x264enc\
! audiomix.\
pulsesrc device=”alsa_input.usb-046d_0825_8C25D680–02-U0x46d0x825.analog-mono”\
! audioconvert\
! ‘audio/x-raw,rate=44100,channels=2’\
! queue\
! voaacenc\
! audiomix. \
avimux name=audiomix ! filesink sync=false location=test.avi

Explanation:

The scripts records video from webcam (v4l2src), grabs contents of X display, record audio from webcam and mixes everything together in one video file.

This is an illustration diagram:

+---------+  +-----------+   +--------------+
| v4l2src | | ximagesrc | | pulsesrc |
+----+----+ +-----+-----+ +------+-------+
| | |
| | |
+----v----+ +-----v-----+ +------v-------+
| queue | | queue | | audioconvert |
+-------+-+ +-+---------+ +------+-------+
| | |
| | |
+---v------v---+ +------v-------+
| videomixer | | queue |
+------+-------+ +------+-------+
| |
| |
+------v-------+ +------v-------+
| videoconvert | | vooaacenc |
+------+-------+ +------+-------+
| |
| |
+------v-------+ +------v-------+
| x264enc +---------> avimux |
+--------------+ +------+-------+
|
|
+----v-----+
| filesink |
+----------+
  • v4l2src is short for Video For Linux version 2 and it allows to record video from webcam
  • ximagesrc grabs video from X display
  • pulsesrc records audio from pulseaudio sound system. To list all available pulseaudio input sources, run following command:
pactl list | grep -A2 ‘Source’ | grep input
  • videomixer allows to mix two video streams together
  • videoconvert, audioconvert allow to convert audio and video frames between different formats if some following pipeline elements are not compatible with format of audio/video stream
  • vooaacenc encodes audio with AAC codec
  • x264enc encodes video with x264 codec
  • avimux mixes audio and video together into AVI container
  • queue allows to enqueue frames from different streams. This is useful when your pipeline doing long blocking operations, e.g. writing data to file or sending data over network. Without this element in your pipeline you will probably lose some frames..
  • filesink stores result of pipeline to the file

Source:

https://medium.com/@KirillMegabozya/smooth-screencast-webcam-picture-in-picture-on-linux-with-gstreamer-2f35ab0cbee

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.