Add memory transfer basics

This commit is contained in:
Matthew Clark 2018-02-25 17:16:08 +00:00
parent 9e4d1a98ac
commit e8b8c51238
2 changed files with 54 additions and 0 deletions

View file

@ -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)

35
memory_transfer.md Normal file
View file

@ -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
````