LibrePlanet: Conference/2016/Streaming

From LibrePlanet
< LibrePlanet:Conference‎ | 2016
Revision as of 17:37, 11 March 2016 by Quidam (talk | contribs) (OpenBroadcaster 2 v4l)
Jump to: navigation, search

Keynote capture script

#!/bin/bash

xid=$(xwininfo  -root -all|grep "Jitsi Meet" | sed -e 's/^ *//' | cut -d\  -f1)
[ 1${xid}1 != 11 ] && xidparameter="xid=$xid"

export GST_DEBUG=4
DATE=$(date +%Y-%m-%d-%H_%M_%S)
PASSWORD=xxx

# pactl list|grep alsa_output
device1="alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00-CODEC.analog-stereo.monitor"
device2="alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00-CODEC.analog-stereo"

gst-launch-1.0 --gst-debug-level=$1 --eos-on-shutdown ximagesrc use-damage=false $xidparameter show-pointer=false !\
 videoconvert ! videorate ! video/x-raw,framerate=20/1 ! videoscale ! video/x-raw, width=1024, height=768 !  \
 vp8enc min_quantizer=1 max_quantizer=10 cpu-used=10 deadline=41000 threads=2 ! queue ! mux. \
 pulsesrc device=$device1 ! adder name=mix ! vorbisenc  quality=0.4 ! queue ! mux. \
 pulsesrc device=$device2 ! mix. \
 webmmux streamable=true name=mux ! queue ! tee name=s ! queue ! filesink location=keynote-${DATE}.webm \
 s. ! queue leaky=2 ! shout2send ip=live2.fsf.org port=80 mount=keynote.webm password=$PASSWORD sync=false 2>&1 |\
 tee keynote-${DATE}.log

OpenBroadcaster 2 v4l

This instructions are for building OpenBroadcaster on Debian testing, plus ffmpeg as a dependency.

NOTE that for OBS to run it is necessary OpenGL 3.2 which is not available in Debian 8 Stable. Follow the install instructions after upgrading to Debian testing.

Building/installing:

Install dependencies:

# apt-get install build-essential pkg-config cmake git checkinstall libx11-dev libgl1-mesa-dev \
libpulse-dev libxcomposite-dev libxinerama-dev libv4l-dev libudev-dev libfreetype6-dev \
libfontconfig-dev qtbase5-dev libqt5x11extras5-dev libx264-dev libxcb-xinerama0-dev \
libxcb-shm0-dev libjack-jackd2-dev libcurl4-openssl-dev zlib1g-dev yasm gstreamer-tools pavucontrol

Download and build ffmpeg:

$ git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git
$ cd ffmpeg
$ ./configure --enable-shared --prefix=/usr
$ make -j4

# checkinstall --pkgname=FFmpeg --fstrans=no --backup=no \
    --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes

Download and build obs:

$ git clone https://github.com/jp9000/obs-studio.git
$ cd obs-studio
$ mkdir build && cd build
$ cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
$ make -j4
# checkinstall --pkgname=obs-studio --fstrans=no --backup=no \
   --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes

Install v4l loop:

# apt-get install v4l2loopback-dkms
# echo v4l2loopback >> /etc/modules
# modprobe v4l2loopback


Install local stream manager:

# apt-get install crtmpserver

Setup

Run obs, set streaming settings to:

  • URL: rtmp://127.0.0.1/flvplayback
  • Stream Key: stream


Run streaming to v4l:

# modprobe snd-aloop
# echo snd-aloop >> /etc/modules
$ gst-launch-1.0 rtmpsrc location="rtmp://127.0.0.1/flvplayback/stream.flv live=1" ! decodebin name=decoded ! videorate !\
video/x-raw,framerate=25/1 ! queue leaky=1 !  v4l2sink device=/dev/video1 sync=false \
decoded. ! audioconvert ! queue leaky=1 ! pulsesink device=alsa_output.1.analog-stereo sync=false

Start Jitsi Meet session on Chromium (recommended browser, others may work).

  • Configure Chromium to use Dummy video device (0x0000) as the video source, and Loopback Analog Stereo as the audio source.
  • Launch pavucontrol and on the Recording tab, set Chromium to record from Monitor of Loopback Analog Stereo.

Caveats

  • This setup introduces ~1s delay on video and audio.

Troubleshooting

Test streaming:

$ gst-launch-1.0 rtmpsrc location="rtmp://127.0.0.1/flvplayback/stream.flv live=1"  ! decodebin ! xvimagesink sync=false

Test v4l device:

$ gst-launch-1.0 v4l2src device=/dev/video1 ! xvimagesink