Version 9 (modified by Adolfo Dunayevich, 5 years 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 (as if you want others to be able to watch a videoconference going on without them being on the room) and here's an easy way to do it with a single command line (3 commands being piped all together).

You would need to use a Debian based distro and install these packages (avconv in inside libav-tools and some packages are specific to wheezy, i.e. ffmpeg is not in jessie or sid):

aptitude install  oggfwd ffmpeg2theora ffmpeg libav-tools pulseaudio-utils 

Then you need to find out what's the output name of you soundcard (as you want to stream what's coming out from your soundcard, not what's going in through your mic) and you can do it this way:

pactl list sources |grep alsa_output

You might directly store the output in a variable so you can use it later. Like this:

export SONIDO=$(pactl list sources |awk '/Name:/ {print $2;exit}')

You also need to get the size of you screen with this one:

xdpyinfo | awk '/dimensions:/ { print $2; exit }'

and you might want to store that in a variable too. Like this:

export PANTALLA=$(xdpyinfo | awk '/dimensions:/ { print $2; exit }')

Finally, you can run this command using the variables you have created already:

avconv  -f pulse -i $SONIDO -f x11grab -s $PANTALLA -r 29 -i :0.0 -target pal-dv -y - |\
ffmpeg2theora - -f dv -F 25:5 --speedlevel 0 --width 360 --height 240 -v 5 -a 5 -c 1 -H 9600 -o - |\
oggfwd   -n 'NOMBRE' -g 'GENERO' -d 'DESCRIPCION' 8000 source /stream-de-prueba.ogv

Please notice you can set the name, genre, and description by replacing the words in CAPITALS. You can also replace the '/stream-de-prueba.ogv' for the right name for your stream, and watch it here:

You can also specify video and audio quality by changing -v and -a (the higher the value the better the quality) respectively.

And here we have a variation of the same scenario, if you wish to stream an audio only session.

export SONIDO=$(pactl list sources|awk '/Name:/ {print $2;exit}')
avconv  -f pulse -i $SONIDO -f ogg - |\
ffmpeg2theora - --no-skeleton --novideo -o - |\
oggfwd   -n 'NOMBRE' -g 'GENERO' -d 'DESCRIPCION' 8000 source /stream-de-prueba.ogg

For more about the parameters you can use please refer to the man pages of every command

avconv ffmpeg2theora oggfwd