LoginSignup
28
29

More than 5 years have passed since last update.

Janus WebRTC Gatewayでライブストリーミング(Raspberry Pi)[メモ]

Last updated at Posted at 2016-06-16
  • Janus WebRTC Gatewayを使って ライブストリーミング Janus4.png

概要

環境

  • Raspberry Pi 3
  • USBのWebCam (Buffalo BSW32K01H - 発売日:2009年11月中旬...ふるい)
  • 2016-05-27-raspbian-jessie-lite.img

手順

  1. いつもの
  2. 基本的なものを入れる

    sudo apt-get install -y build-essential bc git byobu
    

Janusビルド

  1. Janusに必要なものを入れる

    sudo apt-get install -y libmicrohttpd-dev libjansson-dev libnice-dev \
    libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev \
    libopus-dev libogg-dev pkg-config gengetopt libtool automake
    
  2. cd ; git clone https://github.com/meetecho/janus-gateway.git ; cd janus-gateway

  3. sh autogen.sh ; CFLAGS=-I/usr/include/glib-2.0 ./configure --disable-websockets --disable-data-channels --disable-rabbitmq --disable-docs --prefix=/opt/janus ; make

    If you're not interested in Data Channels, WebSockets and/or RabbitMQ (or you don't care about either of them) you can disable them when configuring:

    ビルドが通ればいいので簡単な設定ににげた

  4. sudo make install; sudo make configs

gstreamerとWebサーバ(nginx)

  1. インストール、Janusのファイルのコピー、サービススタートなど

    sudo apt-get install gstreamer1.0-omx gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
    sudo apt-get install nginx
    sudo cp -r /opt/janus/share/janus/demos/ /var/www/html/
    sudo systemctl enable nginx 
    sudo systemctl start nginx 
    
  2. ブラウザで、 http://<らずぱいのIP>/demos/ をみて動作確認
    Janus1.png

WebRTCライブストリーミング

  • コンソールを2つ開く。(byobu使ったり、sshで2つログインする)
    • ひとつはgstreamer起動
    • もうひとつは、janus起動

テスト

  1. cd plugins/streams/;./test_gstreamer_1.sh
    テストスクリプト実行:

    こんな感じ
    pi@raspberrypi:~/janus-gateway$ cd plugins/streams/
    pi@raspberrypi:~/janus-gateway/plugins/streams$ ./test_gstreamer_1.sh 
    Setting pipeline to PAUSED ...
    Pipeline is PREROLLING ...
    Redistribute latency...
    Redistribute latency...
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    
  2. /opt/janus/bin/janus -F /opt/janus/etc/janus/
    janus実行

    こんな感じ
    pi@raspberrypi:~$ /opt/janus/bin/janus -F /opt/janus/etc/janus/
    ---------------------------------------------------
    Starting Meetecho Janus (WebRTC Gateway) v0.1.2
    ---------------------------------------------------
    ...
    ...
    JANUS Unix Sockets transport plugin initialized!
    Unix Sockets thread started
    Sessions watchdog started
    [gstreamer-sample] New video stream! (ssrc=4120554784)
    

    gstreamerが走ってないと、最後の [gstreamer-sample] New video stream!がでない

  3. ブラウザで、http://<らずぱいのIPアドレス>/demos/streamingtest.html を開いて、
    Janus2.png

  4. [Start]をおして、[Stream list]から、[Opus/VP8~]を選択して、[Watch or Listen]を押す。
    Janus3.png

WebCamを使ってみる

  • うちでは、これでうごきました...フレームレート落としたり...順番変えたり..
gst-launch-1.0 -v v4l2src device=/dev/video0 ! videoscale ! \
    video/x-raw,width=320,height=240,framerate=4/1 ! \
    videorate ! videoconvert ! timeoverlay ! \
    vp8enc error-resilient=true ! \
    rtpvp8pay ! udpsink host=127.0.0.1 port=5004

Janus4.png

その他

  • むつかしいこと、わかりません...
  • うまくブラウザに表示されないときは、AdBlockとか NoScriptとか、Ghosteryとか、邪魔してないか見てみよう.
  • ラズパイ公式のCamera(MIPI?CSI?インタフェース)だとフレームレートがいいハズ.そのうち試してみよう.
28
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
29