LibrePlanet: Conference/2016/Streaming

From LibrePlanet
Jump to: navigation, search
(Setup)
Line 34: Line 34:
 
Install dependencies:
 
Install dependencies:
  
    # apt-get install build-essential pkg-config cmake git checkinstall libx11-dev libgl1-mesa-dev \
+
# 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 \
 
  libpulse-dev libxcomposite-dev libxinerama-dev libv4l-dev libudev-dev libfreetype6-dev \
 
  libfontconfig-dev qtbase5-dev libqt5x11extras5-dev libx264-dev libxcb-xinerama0-dev \
 
  libfontconfig-dev qtbase5-dev libqt5x11extras5-dev libx264-dev libxcb-xinerama0-dev \
Line 41: Line 41:
 
Download and build ffmpeg:
 
Download and build ffmpeg:
  
    $ git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git
+
$ git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git
    $ cd ffmpeg
+
$ cd ffmpeg
    $ ./configure --enable-shared --prefix=/usr
+
$ ./configure --enable-shared --prefix=/usr
    $ make -j4
+
$ make -j4
   
+
    # checkinstall --pkgname=FFmpeg --fstrans=no --backup=no \
+
# checkinstall --pkgname=FFmpeg --fstrans=no --backup=no \
        --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes
+
    --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes
  
 
Download and build obs:
 
Download and build obs:
  
    $ git clone https://github.com/jp9000/obs-studio.git
+
$ git clone https://github.com/jp9000/obs-studio.git
    $ cd obs-studio
+
$ cd obs-studio
    $ mkdir build && cd build
+
$ mkdir build && cd build
    $ cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
+
$ cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
    $ make -j4
+
$ make -j4
    # checkinstall --pkgname=obs-studio --fstrans=no --backup=no \
+
# checkinstall --pkgname=obs-studio --fstrans=no --backup=no \
      --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes
+
    --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes
  
 
Install v4l loop:
 
Install v4l loop:
  
    # apt-get install v4l2loopback-dkms
+
# apt-get install v4l2loopback-dkms
    # echo v4l2loopback >> /etc/modules
+
# echo v4l2loopback >> /etc/modules
    # modprobe v4l2loopback
+
# modprobe v4l2loopback
  
  
 
Install local stream manager:
 
Install local stream manager:
  
    # apt-get install crtmpserver
+
# apt-get install crtmpserver
  
 
=== Setup ===
 
=== Setup ===
Line 78: Line 78:
 
Test streaming:
 
Test streaming:
  
    gst-launch-1.0 rtmpsrc location="rtmp://127.0.0.1/flvplayback/stream.flv live=1"  ! decodebin ! xvimagesink sync=false
+
gst-launch-1.0 rtmpsrc location="rtmp://127.0.0.1/flvplayback/stream.flv live=1"  ! decodebin ! xvimagesink sync=false
  
 
Run streaming to v4l:
 
Run streaming to v4l:
  
    gst-launch-1.0 rtmpsrc location="rtmp://127.0.0.1/flvplayback/stream.flv live=1" ! decodebin name=decoded ! videorate !\
+
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 \
 
  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
 
  decoded. ! audioconvert ! queue leaky=1 ! pulsesink device=alsa_output.1.analog-stereo sync=false
Line 88: Line 88:
 
Test v4l device:
 
Test v4l device:
  
    gst-launch-1.0 v4l2src device=/dev/video1 ! xvimagesink
+
  gst-launch-1.0 v4l2src device=/dev/video1 ! xvimagesink

Revision as of 15:42, 11 March 2016

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 8 stable, plus ffmpeg as a dependency.

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

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

Test streaming:

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

Run streaming to v4l:

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

Test v4l device:

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