First bits

This commit is contained in:
Matthew Clark 2018-02-20 12:23:23 +00:00
parent 5cb16f89c2
commit 834c15d948
4 changed files with 187 additions and 1 deletions

View file

@ -1,2 +1,11 @@
# gstreamer-cheat-sheet # gstreamer-cheat-sheet
Gstreamer command-line cheat sheet
This series of docs provides a cheat sheet for Gstreamer on the command-line.
## Contents
* [Test streams](test_streams.md)
* [Basics](basics.md)
* [RTMP](rtmp.md)

123
basics.md Normal file
View file

@ -0,0 +1,123 @@
# Basics (GStreamer command-line cheat sheet)
## Playing content
### Play a video (with audio)
```
gst-launch-1.0 -v playbin uri=file:///Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4
```
or another way
```
gst-launch-1.0 filesrc location=/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4 ! qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink demux.video_0 ! queue ! decodebin ! videoconvert ! videoscale ! autovideosink
```
# Play a video (no audio)
```
gst-launch-1.0 -v uridecodebin uri="file:///Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! autovideosink
```
which could also have been done as:
```
gst-launch-1.0 -v filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! decodebin ! autovideosink
```
To play a video (just audio, no video):
```
gst-launch-1.0 -v uridecodebin uri="file:///Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! autoaudiosink
```
Audio visualisation:
```
gst-launch-1.0 filesrc location=/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4 ! qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! wavescope ! autovideosink
```
(or replace wavescope with spectrascope or synaescope or spacescope)
Or even better visualisation:
```
gst-launch-1.0 filesrc location=/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4 ! decodebin ! tee name=t ! queue ! audioconvert ! wavescope style=color-lines shade-amount=0x00080402 ! alpha alpha=0.5 ! videomixer name=m background=black ! videoconvert ! vertigotv ! autovideosink t. ! queue ! audioconvert ! spacescope style=color-lines shade-amount=0x00080402 ! alpha alpha=0.5 ! m. t. ! queue ! autoaudiosink
```
Go slightly mad:
```
gst-launch-1.0 -v filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! decodebin ! videoconvert ! vertigotv ! autovideosink
```
Try also rippletv, streaktv, radioactv, optv, quarktv, revtv, shagadelictv, warptv (I like), dicetv, agingtv (great), edgetv (could be great on real stuff)
## Resize video
```
gst-launch-1.0 -v filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=100 ! autovideosink
```
Change framerate
```
gst-launch-1.0 -v filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! decodebin ! videoconvert ! videorate ! video/x-raw,framerate=5/1 ! autovideosink
```
And of course you can resize the video and change the framerate:
```
gst-launch-1.0 -v \
filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4” ! \
decodebin ! videoconvert ! videoscale ! video/x-raw,width=100 ! videorate ! video/x-raw,framerate=5/1 ! \
autovideosink
```
## Picture in picture
```
gst-launch-1.0 \
filesrc location="/Users/clarkm22/workspace/silver/assets/20161017-224500-match-of-the-day-2-h264lg.mp4" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=640,height=360 ! \
videomixer name=mix sink_0::alpha=1 sink_1::alpha=1 ! \
videoconvert ! autovideosink \
filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=320,height=180! \
mix.
```
Put a box around the in-picture using videobox e.g.
```
gst-launch-1.0 \
filesrc location="/Users/clarkm22/workspace/silver/assets/20161017-224500-match-of-the-day-2-h264lg.mp4" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=640,height=360 ! \
videomixer name=mix sink_0::alpha=1 sink_1::alpha=1 ! \
videoconvert ! autovideosink \
filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=320,height=180! \
videobox border-alpha=0 top=-10 bottom=-10 right=-10 left=-10 ! \
mix.
```
Choose where the in-picture goes with the xpos and ypos attributes of videomixer, e.g.
```
gst-launch-1.0 \
filesrc location="/Users/clarkm22/workspace/silver/assets/20161017-224500-match-of-the-day-2-h264lg.mp4" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=640,height=360 ! \
videomixer name=mix sink_0::alpha=1 sink_1::alpha=1 sink_1::xpos=50 sink_1::ypos=50 ! \
videoconvert ! autovideosink \
filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=320,height=180! \
mix.
```

35
rtmp.md Normal file
View file

@ -0,0 +1,35 @@
# RTMP (GStreamer command-line cheat sheet)
GStreamer can receive an RTMP stream from an RTMP server. It can also send an RTMP stream to an RTMP server.
If you need your own RTMP server, [the Nginx RTMP extension](https://github.com/arut/nginx-rtmp-module) works quite well though is no longer supported.
### Play an RTMP stream
To play from RTMP server, at the path `/live/x`, with the server name in the environment variable `RTMP_SERVER`:
```
gst-launch-1.0 uridecodebin uri='rtmp://$RTMP_SERVER/live/x' ! \
videoconvert ! videorate ! videoscale ! videoconvert ! \
video/x-raw, format=BGRA, pixel-aspect-ratio=1/1, interlace-mode=progressive,framerate=24/1, width=640, height=360 ! \
autovideosink
```
Russia Today is available over RTMP at `https://rtmp.api.rt.com/hls/rtdru360.m3u8`. So you can watch it with:
```
gst-launch-1.0 uridecodebin uri='https://rtmp.api.rt.com/hls/rtdru360.m3u8' ! \
videoconvert ! videorate ! videoscale ! videoconvert ! \
video/x-raw, format=BGRA, pixel-aspect-ratio=1/1, interlace-mode=progressive,framerate=24/1, width=640, height=360 ! \
autovideosink
```
### Stream TO an RTMP server
At the path '/live/x', with the server name in the environment variable `RTMP_SERVER`:
```
gst-launch-1.0 videotestsrc \
is-live=true ! queue ! x264enc ! flvmux name=muxer ! \
rtmpsink location='rtmp://$RTMP_SERVER/live/x'
```

19
test_streams.md Normal file
View file

@ -0,0 +1,19 @@
# Test streams (GStreamer command-line cheat sheet)
Display a test pattern:
```
gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
```
Listen to a test audio (beep):
```
gst-launch-1.0 audiotestsrc ! audioconvert ! autoaudiosink
```
Combine both the test pattern and test audio:
```
gst-launch-1.0 audiotestsrc ! autoaudiosink videotestsrc ! autovideosink
```