From e365f6a1c152aaf937326a8c703af678f4dba1a4 Mon Sep 17 00:00:00 2001 From: Matthew Clark Date: Tue, 20 Feb 2018 12:32:33 +0000 Subject: [PATCH] Improve mixing --- README.md | 1 + basics.md | 89 +++++++++++++++++-------------------------------------- mixing.md | 50 +++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 62 deletions(-) create mode 100644 mixing.md diff --git a/README.md b/README.md index e32379a..df5771d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ This series of docs provides a cheat sheet for Gstreamer on the command-line. * [Test streams](test_streams.md) * [Basics](basics.md) * [RTMP](rtmp.md) +* [Mixing video](mixing.md) ## Sources and references diff --git a/basics.md b/basics.md index 3111bcd..be95d05 100644 --- a/basics.md +++ b/basics.md @@ -2,55 +2,66 @@ ## 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) ``` -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) ``` -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: ``` -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: ``` -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: - ``` -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) @@ -58,66 +69,20 @@ Try also ‘rippletv’, ‘streaktv’, ‘radioactv’, ‘optv’, ‘quarktv ### 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 ``` -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: ``` 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 ! \ 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. -``` diff --git a/mixing.md b/mixing.md new file mode 100644 index 0000000..61a2ceb --- /dev/null +++ b/mixing.md @@ -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. +``` +