From e8b8c51238c24803edb62e634999402e7a3b70be Mon Sep 17 00:00:00 2001 From: Matthew Clark Date: Sun, 25 Feb 2018 17:16:08 +0000 Subject: [PATCH] Add memory transfer basics --- README.md | 19 +++++++++++++++++++ memory_transfer.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 memory_transfer.md diff --git a/README.md b/README.md index 2e3ff9f..3505535 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This series of docs provides a cheat sheet for Gstreamer on the command-line. * [RTMP](rtmp.md) * [Mixing video](mixing.md) * [Capturing images](capturing_images.md) +* [Sending/receiving video from shared memory](memory_transfer.md) ## Sources and references @@ -22,3 +23,21 @@ This series of docs provides a cheat sheet for Gstreamer on the command-line. * http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet * https://github.com/xmementoit/gstreamerCheatsheet/blob/master/README.md +## Interaction + +If you want to interact with GStreamer after it's started (e.g. respond to an event, or dynamically change a pipeline), the command-line GStreamer doesn't really cut it. Instead you have two options: + +* *[GStreamer Daemon (gstd)](https://github.com/RidgeRun/gstd-1.x)* - allows setting and updating via a TCP connection +* *Develop using the GStreamer library*, in either [C](https://gstreamer.freedesktop.org/documentation/application-development/basics/helloworld.html), [Python](https://github.com/GStreamer/gst-python), or [C#/.NET](https://github.com/GStreamer/gstreamer-sharp) + +### Python with GStreamer + +Good GStreamer Python resources include: + +* [Python GStreamer Tutorial](http://brettviren.github.io/pygst-tutorial-org/pygst-tutorial.html) +* [Function reference](http://lazka.github.io/pgi-docs/#GstApp-1.0) + +# Problems or suggestions with this guide? + +If you spot anything incorrect or incomplete, reports are welcome, either using [issues](issues) or [pull requests](pulls) + diff --git a/memory_transfer.md b/memory_transfer.md new file mode 100644 index 0000000..a61d1be --- /dev/null +++ b/memory_transfer.md @@ -0,0 +1,35 @@ +# Capturing images (GStreamer command-line cheat sheet) + +The [`shmsink`](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad/html/gst-plugins-bad-plugins-shmsink.html) element allows you to write video into shared memory, from which another gstreamer application can read it with [`shmsrc`](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad/html/gst-plugins-bad-plugins-shmsrc.html). + +### Puttingn a stream into memory + +``` +gst-launch-1.0 -v videotestsrc ! \ + 'video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1' ! \ + queue ! identity ! \ + shmsink wait-for-connection=1 socket-path=/tmp/tmpsock shm-size=20000000 sync=true +``` + +Another example, this time from a file rather than test source, and keeping the audio local: + +``` +gst-launch-1.0 filesrc location=$SRC ! \ + qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! \ + autoaudiosink \ + demux.video_0 ! queue ! \ + decodebin ! videoconvert ! videoscale ! videorate ! \ + 'video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1' ! \ + queue ! identity ! \ + shmsink wait-for-connection=0 socket-path=/tmp/tmpsock shm-size=20000000 sync=true +``` + +### Reading a stream from memory + +``` +gst-launch-1.0 shmsrc socket-path=/tmp/tmpsock ! \ + 'video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1' ! \ + autovideosink +```` + +