Improve mixing

This commit is contained in:
Matthew Clark 2018-02-20 12:32:33 +00:00
parent a1aa851c7d
commit e365f6a1c1
3 changed files with 78 additions and 62 deletions

View file

@ -7,6 +7,7 @@ This series of docs provides a cheat sheet for Gstreamer on the command-line.
* [Test streams](test_streams.md) * [Test streams](test_streams.md)
* [Basics](basics.md) * [Basics](basics.md)
* [RTMP](rtmp.md) * [RTMP](rtmp.md)
* [Mixing video](mixing.md)
## Sources and references ## Sources and references

View file

@ -2,55 +2,66 @@
## Playing content ## Playing content
For these,set `SRC` to be e.g. an mp4 file., e.g.
```
export SRC=/home/me/videos/test.mp4
```
### Play a video (with audio) ### Play a video (with audio)
``` ```
gst-launch-1.0 -v playbin uri=file:///Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4 gst-launch-1.0 -v playbin uri=file://$SRC
``` ```
or another way or, if you'd rather have more control of the pipeline:
``` ```
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 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 ! autovideosink
``` ```
### Play a video (no audio) ### 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 gst-launch-1.0 -v uridecodebin uri="file://$SRC" ! autovideosink
``` ```
which could also have been done as: 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 gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! autovideosink
``` ```
To play a video (just audio, no video): ### Play just the audio from a video
``` ```
gst-launch-1.0 -v uridecodebin uri="file:///Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4" ! autoaudiosink gst-launch-1.0 -v uridecodebin uri="file://$SRC" ! autoaudiosink
``` ```
Audio visualisation: ### Visualise the audio:
``` ```
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 gst-launch-1.0 filesrc location=$SRC ! qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! wavescope ! autovideosink
``` ```
(or replace wavescope with spectrascope or synaescope or spacescope) (or replace `wavescope` with `spectrascope` or `synaescope` or `spacescope`)
Or even better visualisation: 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 gst-launch-1.0 filesrc location=$SRC ! 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
``` ```
### Add filters
Go slightly mad: 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 gst-launch-1.0 -v filesrc location="$SRC" ! 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) Try also rippletv, streaktv, radioactv, optv, quarktv, revtv, shagadelictv, warptv (I like), dicetv, agingtv (great), edgetv (could be great on real stuff)
@ -58,66 +69,20 @@ Try also rippletv, streaktv, radioactv, optv, quarktv
### Resize video ### 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 gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=100 ! autovideosink
``` ```
### Change framerate ### 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 gst-launch-1.0 -v filesrc location="$SRC" ! decodebin ! videoconvert ! videorate ! video/x-raw,framerate=5/1 ! autovideosink
``` ```
And of course you can resize the video and change the framerate: And of course you can resize the video and change the framerate:
``` ```
gst-launch-1.0 -v \ gst-launch-1.0 -v \
filesrc location="/Users/clarkm22/workspace/silver/assets/20160920-184500-danger-mouse-h264lg.mp4” ! \ filesrc location="$SRC” ! \
decodebin ! videoconvert ! videoscale ! video/x-raw,width=100 ! videorate ! video/x-raw,framerate=5/1 ! \ decodebin ! videoconvert ! videoscale ! video/x-raw,width=100 ! videorate ! video/x-raw,framerate=5/1 ! \
autovideosink 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.
```

50
mixing.md Normal file
View file

@ -0,0 +1,50 @@
# Mixing video (GStreamer command-line cheat sheet)
### Picture in picture
Here we have two source (mp4) files, which should be set as environment variables `$SRC` and `$SRC2`
```
gst-launch-1.0 \
filesrc location="$SRC2" ! \
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="$SRC" ! \
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="$SRC2" ! \
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="$SRC" ! \
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="$SRC2" ! \
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="$SRC" ! \
decodebin ! videoconvert ! \
videoscale ! video/x-raw,width=320,height=180! \
mix.
```