Giter Club home page Giter Club logo

gst-zeromq's Introduction

gst-zeromq

Introduction

gst-zeromq provides GStreamer elements for moving data with ZeroMQ.

Specifically, it supports ZeroMQ PUB/SUB sockets via a sink (zmqsink) which provides a PUB endpoint, and a source (zmqsrc) that uses a SUB socket to connect to a PUB.

Other ZeroMQ topologies may be implemented in the future.

gst-zeromq is written in C for GStreamer 1.x, using the usual GStreamer GLib C idiom.

It has been developed and tested with:

  • Ubuntu Trusty Tahr (14.04)
  • GStreamer 1.2.4 packages available on Trusty (but any 1.x should work)
  • ZeroMQ 4.1.1 (but any version back to 2.2.0 should work)

Git repo at http://github.com/mjhowell/gst-zeromq

Required packages (for Ubuntu, as of Mar 2018)

Install the required packages as:

$ sudo apt-get install dh-autoreconf libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libzmq3-dev

Build It

On Ubuntu, you'll need at least build-essential and libgstreamer1.0-dev installed. Then, to build:

$ ./autogen.sh

$ make

The libs will be built in src/zeromq/.libs. To test them in place without installing, run the gst-zeromq-vars script:

$ . gst-zeromq-vars.sh

Now see if GStreamer can find the libs and catalog the elements:

$ gst-inspect-1.0 zmqsrc

You should see something like this:

Factory Details:
Rank                     none (0)
Long-name                ZeroMQ source
Klass                    Source/Network
Description              Receive data on ZeroMQ SUB socket

...

is-live             : If true, act as a live source
                      flags: readable, writable
                      Boolean. Default: true
do-timestamp        : Apply current stream time to buffers
                      flags: readable, writable
                      Boolean. Default: false
endpoint            : ZeroMQ endpoint from which to receive buffers
                      flags: readable, writable
                      String. Default: "tcp://localhost:5556"
bind                : If true, bind to the endpoint (be the "server")
                      flags: readable, writable
                      Boolean. Default: false

Try It

With stdin/stdout

In one terminal, start a "server":

$ gst-launch-1.0 fdsrc fd=0 ! zmqsink

In another terminal, start a "client":

$ gst-launch-1.0 zmqsrc ! fdsink fd=1

When you type in a line of text at the server and hit Enter, the text will show at the client.

Stop each side with Ctrl-C.

With Video

In one terminal, start a "server":

$  gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! zmqsink

In another terminal, start a "client":

$ gst-launch-1.0 zmqsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! autovideosink

Note caps are specified here because this is two separate pipelines with no cap negotiation happening between them.

ZeroMQ PUB/SUB in action

With ZeroMQ PUB/SUB, multiple SUBs can connect to one PUB. PUBs and SUBs can come and go at will, and reconnect automatically.

Let's start a server (which provides a PUB endpoint):

$  gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! zmqsink

Then in two separate terminals, start two clients (which SUB to the server's PUB):

$ gst-launch-1.0 zmqsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! autovideosink

and

$ gst-launch-1.0 zmqsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! autovideosink

Stop and restart a client. It will start to play again.

Stop and restart the server. Both clients will stop playing, then reconnect and start playing again.

You can start and stop the server and clients in any order, and they will connect and play. You can connect any number of clients (SUBs) to the server's PUB, within the limitations of your system.

Servers and clients can be on different systems as long as the PUB endpoint is reachable by clients over the network, just change the endpoint from the default. Multiple streams can be served on the same system by changing the endpoint's port number or protocol type. See the ZeroMQ docs for more information about endpoints and protocols.

License

This project uses the GNU LGPL. See COPYING and COPYING.LIB.

TODO

  • move zmq context into class (one context for all instances)?
  • destroy zmq context on release
  • fix src getting stuck in create() after stopping pipeline.
  • zero copy possible, rather than memcpy() between mapped GstBuffer and zmq_msg_t?
  • correct reset behavior... works OK in gst-launch cmdline but not in apps.

gst-zeromq's People

Contributors

danielzel avatar mjhowell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gst-zeromq's Issues

Cannot run autogen.sh

Hi there! thank you for this amazing project, I am working on a problem that needs exactly this solution. The problem with me is that I cloned the repository and ran autoconf.sh. I found out that it needs a package dh-autoconf so I installed it using

$ sudo apt-get install dh-autoconf

I then ran it again, this time it did not give me a command not found error, it gives me some errors.

muhammadsalarkhan@viper:~/AMK/ZMQ-GST/gst-zeromq$ ./autogen.sh 
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force 
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac,
libtoolize: and rerunning libtoolize and aclocal.
libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
autoreconf: running: /usr/bin/autoconf --force
configure.ac:29: error: possibly undefined macro: AC_MSG_ERROR
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:35: error: possibly undefined macro: AC_SUBST
autoreconf: /usr/bin/autoconf failed with exit status: 1
autogen.sh failed

Any help would be greatly appreciated. ๐Ÿ‘

ZeroMQ and RGB

Hi all,
Is it possible to run a gst pipeling using RGB as video/x-raw format? Or just I420 is supported?
I am trying to use RGB instead of I420. On the publisher pipeline i get no error, but executing the subscriver pipeline I get the following error:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format
Additional debug info:
gstcapsfilter.c(453): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:
Output caps are unfixed: EMPTY
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

Publisher pipeline:
gst-launch-1.0 vimbasrc camera=DEV_XXX settingsfile=1216_1936.xml ! video/x-raw, format=RGB, width=1936, height=1216 ! queue ! zmqsink endpoint=tcp://192.168.1.10:5555

Subscriber pipeline:
gst-launch-1.0 zmqsrc endpoint=tcp://192.168.1.10:5555 ! video/x-raw, format=RGB, width=1936, height=1216, framerate=30/1 ! queue ! autovideosink

The fact is that I need an RGB output and if I try to convert I420 to RGB I get the same error. In this case publisher and subscriber are this:

Publisher pipeline:
gst-launch-1.0 vimbasrc camera=DEV_XXX settingsfile=1216_1936.xml ! video/x-raw,format=RGB ! videoconvert ! video/x-raw, format=I420, width=1936, height=1216 ! queue ! zmqsink endpoint=tcp://192.168.1.10:5555

Subscriber pipeline:
gst-launch-1.0 zmqsrc endpoint=tcp://192.168.1.10:5555 ! video/x-raw, format=I420, width=1936, height=1216, framerate=30/1 ! videoconvert ! video/x-raw,format=RGB ! queue ! autovideosink

Do you have any idea, please?

do-timestamp option doesn't work properly

Example 1:

gst-launch-1.0 zmqsrc endpoint=tcp://127.0.0.1:50001 do-timestamp=true ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! fpsdisplaysink video-sink=fakesink

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
0:00:00.131577308  3983 0xaaaaf07ad300 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<zmqsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.157475986  3983 0xaaaaf07ad300 WARN         basetextoverlay gstbasetextoverlay.c:3049:gst_base_text_overlay_video_chain:<fps-display-text-overlay> buffer without timestamp, discarding
0:00:00.175540121  3983 0xaaaaf07ad300 WARN         basetextoverlay gstbasetextoverlay.c:3049:gst_base_text_overlay_video_chain:<fps-display-text-overlay> buffer without timestamp, discarding
0:00:00.186531106  3983 0xaaaaf07ad300 WARN         basetextoverlay gstbasetextoverlay.c:3049:gst_base_text_overlay_video_chain:<fps-display-text-overlay> buffer without timestamp, discarding

Example 2:

gst-launch-1.0 zmqsrc endpoint=tcp://127.0.0.1:50001 do-timestamp=true ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! videorate ! video/x-raw, framerate=5/1 ! fakesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
0:00:00.104167037  4399 0xaaaad89ccb60 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<zmqsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.132224210  4399 0xaaaad89ccb60 WARN               videorate gstvideorate.c:1789:gst_video_rate_transform_ip:<videorate0> Got buffer with GST_CLOCK_TIME_NONE timestamp, discarding it
0:00:00.147644262  4399 0xaaaad89ccb60 WARN               videorate gstvideorate.c:1789:gst_video_rate_transform_ip:<videorate0> Got buffer with GST_CLOCK_TIME_NONE timestamp, discarding it
0:00:00.165624864  4399 0xaaaad89ccb60 WARN               videorate gstvideorate.c:1789:gst_video_rate_transform_ip:<videorate0> Got buffer with GST_CLOCK_TIME_NONE timestamp, discarding it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.