From eeed1a54f7b67da05cec214ca53dbf7e28f32dd4 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Fri, 20 Mar 2020 17:21:40 -0400 Subject: [PATCH] Comments and formatting --- streamdesktop | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/streamdesktop b/streamdesktop index f963025..925a4da 100755 --- a/streamdesktop +++ b/streamdesktop @@ -30,22 +30,23 @@ fi # Server side dependencies: icecast2 - -DATE=$(date +%Y-%m-%d-%H_%M_%S) -PASSWORD=hackme +# Server connection settings SERVER=my.icecast2server.org -PORT=80 -MOUNT=$1 -[ "$MOUNT" = "" ] && MOUNT=recording -BITRATE=1000000 -SOUNDQUALITY=0.4 -FRAMERATE=20 -SHOWPOINTER="true" +PORT=80 # port to stream to +PASSWORD=hackme + +# Stream settings +BITRATE=1000000 # Bitrate of the video, in bps +SOUNDQUALITY=0.4 # OGG compression quality, from 0 to 1 +FRAMERATE=20 # frames per second +SHOWPOINTER="true" # show or hide the mouse pointer # Width and height are upper limits. Video will not be upscaled or stretched, it would be proportionally downscaled to fit the WIDTH and HEIGHT dimensions WIDTH=1280 HEIGHT=720 -WINDOWLIST="$(wmctrl -l)" +DATE=$(date +%Y-%m-%d-%H_%M_%S) +MOUNT=$1 +[ "$MOUNT" = "" ] && MOUNT=recording cat << EOF Usage: $0 [title] @@ -56,18 +57,20 @@ The title parameter will be used for the name of the mount, and the name of the AUDIO INPUT: this script will record and stream the audio from the default input selection in Pulseaudio. Click on the volume icon in your desktop environment, go to settings, then input, and select the appropriate device and input level. -SCREEN SELECTION. Note: broadcasting a single window may crash if you minimize or resize the screen after the streaming starts! If you have issues with this, select 0 to broadcast the full screen, but remember to close or hide any privacy-sensitive windows." +SCREEN SELECTION. Note: broadcasting a single window may crash if you minimize or resize the screen after the streaming starts! If you have issues with this, select 0 to broadcast the full screen, but remember to close or hide any privacy-sensitive windows." If the stream is just an empty black square, make sure your desktop is running X11, not Wayland or others. 0: Capture FULL SCREEN EOF +# Window selector +WINDOWLIST="$(wmctrl -l)" i=1 echo "$WINDOWLIST" |while read line do - echo -n "$i: " - name=$(echo $line| cut -d' ' -f 4-) - echo $name - i=$(expr $i + 1) + echo -n "$i: " + name=$(echo $line| cut -d' ' -f 4-) + echo $name + i=$(expr $i + 1) done echo @@ -77,11 +80,13 @@ read -s -n1 SELECTION XID=$(echo "$WINDOWLIST" | sed -n "${SELECTION}p" | sed 's/ .*//') if [ "$SELECTION" = 0 ] || [ "$SELECTION" = "" ] ; then - XPARAM="" + XPARAM="" else - XPARAM="xid=$XID" + XPARAM="xid=$XID" fi + +# The video needs to be processed after recording trap ctrl_c INT ctrl_c() { echo @@ -96,11 +101,13 @@ ctrl_c() { echo ffmpeg -i $MOUNT-${DATE}.webm -acodec copy -vcodec copy -ss 00:19:27 -to 02:18:51 trimmed.webm } + echo STARTING STREAM in 2 seconds. Press CTRL+C to end the session. sleep 2 echo Streaming at http://$SERVER/recording.webm echo +# GSTREAMER 1.0 pipeline for capture, save to file, and stream to icecast2 gst-launch-1.0 --eos-on-shutdown ximagesrc use-damage=false $XPARAM show-pointer=$SHOWPOINTER \ ! videorate ! video/x-raw,framerate=$FRAMERATE/1 \ ! videoscale ! video/x-raw, width=$WIDTH, height=$HEIGHT \ -- 2.25.1