LoginSignup
30
27

More than 5 years have passed since last update.

UV4L使ってRaspberry pi2でWebRTCでブラウザに動画表示

Last updated at Posted at 2015-08-03

apt-getでインストールして再起動してサービス立ち上がって9000番ポートにブラウザでアクセスすると動画や静止画が表示されました。

参考サイト

構成

  • Raspberry Pi 2
  • OS/Kernel (uname -a): Raspbian / Linux raspberrypi 3.18.7-v7+ #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 armv7l GNU/Linux

インストール

パッケージ構成

$ curl http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc | sudo apt-key add -
$ sudo vi /etc/apt/sources.list (最後の行を追加)
$ cat /etc/apt/sources.list
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main

パッケージインストール、サービス再起動

$ sudo apt-get update
$ sudo apt-get install uv4l-webrtc
$ sudo apt-get install uv4l-raspicam-extras
$ sudo service uv4l_raspicam restart

ここでカメラを有効にしてRaspberry pi再起動

$ sudo raspi-config

設定ファイル

/etc/uv4l/uv4l-raspicam.conf で--server-optionをコメントを外して明示的に指定してみました。(デフォルトのままでもいいかも)
追記:encodingをh264に設定して動作させることもできたので、変更してみました。
(2015/8/5追記:h264に指定してもブラウザに届くデータはH264ではなくVP8になっているようでした、原因を探っています。)

#(コメント一部省略)
#
# uv4l core options
#

driver = raspicam
# video_nr = 0
auto-video_nr = yes
syslog-host = localhost

#
# raspicam options
#

encoding = h264
# width = 640
# height = 480
framerate = 30

# text-overlay = yes
# text-filename = /usr/share/uv4l/raspicam/text.json
# object-detection = no
# object-detection-mode = accurate_tracking
### for multi argument options you must specify one arg per line,
## i.e. --min-object-size 80 80 is:
# min-object-size = 80
# min-object-size = 80

# main-classifier = /usr/share/uv4l/raspicam/lbpcascade_frontalface.xml
# secondary-classifier =/usr/share/uv4l/raspicam/lbpcascade_frontalface.xml

# nopreview = yes

# sharpness = 0
# contrast = 0 
# brightness = 50
# saturation = 0
# iso = 400
# vstab = yes
# ev = 0
# exposure = auto
# awb = auto
# imgfx = none
# metering = average
# rotation = 0
# hflip = no
# vflip = no
# shutter-speed = 0
# drc = off

#
# streaming server options
#

server-option = --port=9000
server-option = --user-password=myp4ssw0rd
server-option = --admin-password=myp4ssw0rd

# To enable 'config' user authentication
server-option = --config-password=myp4ssw0rd

Jpeg出力test

$ uv4l --driver raspicam --auto-video_nr --width 640 --height 480 --encoding jpeg
$ sudo dd if=/dev/video0 of=snapshot.jpeg bs=11M count=1

WebRTC 画面アクセス

Mac OSX 10.10.4でFirefox-39.0 Chrome-44.0.2403.125 (64-bit)で表示可能

open http://<ラズパイのIPアドレス>:9000/stream/webrtc

画面の認証はユーザー名admin パスワードは—admin-passwordで指定したもの

表示されるメニュー

  • edit configuration file << パスワードは--config-passwordで指定したもの
  • camera control panel << このページでビデオのフォーマットをH264などに変更可能
  • audio/video stream via WebRTC << このページを表示してstartボタンをクリックして動画を表示
  • video stream in MJPEG or JPEG (still captures)
  • multi peer-to-peer audio/video conferencing
  • stream audio/video to a Jitsi Meet Web Conference (what is Jitsi Meet?)
30
27
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
30
27