wiki:StreamDesktop

Version 10 (modified by Jamie McClelland, 12 months ago) (diff)

--

Streaming what is on your desktop

See also how to stream live video from your camera.

You might need to stream everything happening in you desktop.

You would need to use a Debian based distro and install these packages:

sudo apt install ffmpeg pulseaudio-utils 

Next, create a configuration file called .config/stream-desktop and add the following to it (change as needed):

# This file is sourced by the stream-desktop script

# Set output device. Use the command: `pactl list sources | grep alsa_output` to find the
# right one. If you have a USB headset or some other device, it might not be the alsa device
# that is the active one.
output=alsa_output.usb-SADES_Electronics_Inc._SADES_Snuk-00.analog-stereo.monitor

# Set the icecast server URL, including password. 
server="icecast://source:CHANGEME@a.stream.mayfirst.org:8000/meeting.webm"

# Set your screen dimensions. For performance reasons I am keeping it very low.
# If you want to set it to your maximum resolution for your monitor, you can
# find your dimensions with: `xdpyinfo | awk '/dimensions:/ { print $2; exit }'`
dimensions=640x480

# video bits is the main quality marker. .15M seems the lowest you can go without
# sacrificing too much quality. 1.5M gives really good video quality, but doesn't
# play too well.
video_bits=.15M

name="May First/People Link"
description="MF/PL annual Membership Meeting"

Lastly, create a file called stream-desktop in your ~/bin directory and add the following:

#!/bin/bash

config_file=~/.config/stream-desktop
if [ ! -f "$config_file" ]; then
  printf "Please create the file %s and set all configuration parameters.\n" "$config_file"
  exit 1
fi
source "$config_file"

ffmpeg -loglevel info \
  -f x11grab -show_region 1 -thread_queue_size 32 -video_size "$dimensions" -framerate 30 -i :0.0  \
  -f pulse  -i "$output" \
  -f webm -af aresample=async=1 -cluster_size_limit 2M -cluster_time_limit 5100 -content_type video/webm \
  -c:a libvorbis -b:a 96K \
  -c:v libvpx -b:v "$video_bits" -crf 30 -g 30 -deadline good -threads 3 \
  "$server"