gstreamer-cheat-sheet/memory_transfer.md

38 lines
1.6 KiB
Markdown
Raw Normal View History

2018-02-25 17:16:08 +00:00
# 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).
### Putting a stream into memory
2018-02-25 17:16:08 +00:00
2018-04-17 23:00:13 +00:00
Put a test video source into memory:
2018-02-25 17:16:08 +00:00
```
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
2018-04-17 23:00:13 +00:00
This will display the video of a stream locally:
2018-02-25 17:16:08 +00:00
```
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
````