Gstreamer

gstreamer is tinker toys for putting together media applications. Very reminiscent of gnuradio although it doesn’t have a nice gui editor. You smash together a bunch of blocks

It keeps coming up so I am looking into it more.

 

https://gstreamer.freedesktop.org/documentation/installing/on-linux.html

sudo apt install libgstreamer1.0-dev

copy example

https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html#

gcc hello_gstream.c pkg-config --cflags --libs gstreamer-1.0

 

v4l2src is the webcam source of the /dev/video0 device

 

apt-get install gstreamer0.10-ffmpeg

gst-launch-1.0 -v \
v4l2src \
! qtdemux \
! h264parse \
! ffdec_h264 \
! ffmpegcolorspace \
! x264enc \
! rtph264pay \
! udpsink host=127.0.0.1 port=5000

helpful idiom

gst-inspect | grep “h264”

This let me view my webcam

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! xvimagesink

The video/x-raw is a “cap”, a capability, kind of defining the type of video flowing through. It isn’t a conversion step as I understand it. It is telling the graph which of the possible types of video available you’ve picked (your webcam can just be told to give you different stuff).

Ugh. The gstreamer elements are super useful, but where is an organized list of them. The manual just has a big dump. Most of these are probably not useful.

https://gstreamer.freedesktop.org/documentation/plugins.html

videoconvert sounds like a good one

There are some fun opencv and opengl ones. Like face detection or wacky effects. Handdetect is a curious one

fakesrc for testing

special sinks for os x –  osxvideosink

playbin for playing from a uri

x264enc – encodes into h264

uvch264 – gets a h264 stream right from the webcam

Using the Logitech C920 webcam with Gstreamer 1.2

Or you can just change the parameter to v4l2src to output h264. Ok this is not working on my webcam. I get

ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.

instead

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=640,height=480 ! x264enc tune=zerolatency !  h264parse ! avdec_h264 ! xvimagesink

encodes h264 and then decodes it. May want to change that zerolatency to another setting option. Maybe?

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-ugly-plugins/html/gst-plugins-ugly-plugins-x264enc.html

 

okay continuing ahead with the streaming. I can’t get h264 to stream. It gives a ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data flow error. when combined with the stock example code

GARBAGE. DO NOT USE.

 

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-rtpbin.html

However. using h263 it does work. Needed to change ffenc to avenc from their example and ffdec to avdec

Sending

receiving

 

for receiving on my macbook

gst-launch-1.0 -v rtpbin name=rtpbin \

you need to specify a host for the udpsinks to get the video on another computer.

I would estimate the latency at 1/4 second maybe. Much better than other things I’ve tried.

okay default latency on rtpbin is 200ms.

on receiving side set latency=0 as an option to rtpbin (not totally sure if transmitting side should have it too.)

I wonder how bad that will fail in the event of packet loss? It’s probably not a good setting for some circumstances, but for a non-critical application on a LAN it seems pretty good.

I think the latency might have crept up a bit over a minute. Not too bad though.

 

https://github.com/GStreamer/gst-rtsp-server

 

Leave a Reply

Your email address will not be published. Required fields are marked *