メモ > 技術 > 開発: RaspberryPi > 動画のストリーミング配信
動画のストリーミング配信
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install -y cmake libv4l-dev libjpeg-dev imagemagick
$ git clone https://github.com/jacksonliam/mjpg-streamer.git
$ cd mjpg-streamer/mjpg-streamer-experimental
$ make
$ sudo make install
$ sudo /usr/local/bin/mjpg_streamer -i "input_uvc.so -f 30 -r 640x480 -d /dev/video0 -q 80" -o "output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www"
MJPG Streamer Version: git rev: 85f89a8c321e799fabb1693c5d133f3fb48ee748
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 30
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
UVCIOC_CTRL_ADD - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Mode: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Frequency: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Disable video processing: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (25)
o: www-folder-path......: /usr/local/share/mjpg-streamer/www/
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: enabled
「UVCIOC_CTRL_ADD - Error」が表示されているが、動作には問題ないみたい。
以下にアクセスし、左メニューから「Stream」を選択するとカメラの動画を表示できる
http://192.168.1.202:8080/
もしくは、以下にアクセスすれば動画を直接取得できる
http://192.168.1.202:8080/?action=stream
Raspberry Pi ×カメラモジュールで動画配信(ストリーミング)してみる - 自作のいろいろ
https://garchiving.com/streamed-on-raspberry-pi/
Raspberry Pi3にmjpg-streamerを入れる - Qiita
https://qiita.com/lobmto/items/c31e0c8136c16f75b1cd
■動画の回転
以下のように「-rot 180」を指定すれば、上下回転して表示できる。
$ sudo /usr/local/bin/mjpg_streamer -i "input_uvc.so -f 30 -r 640x480 -rot 180 -d /dev/video0 -q 80" -o "output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www"
Raspberry Pi B で監視カメラ | n10の個人的なメモ
https://mirahouse.jp/n10/blog/2019/raspberry-pi-b-camera/
終了させたい場合、Ctrl+C を入力する。
■JavaScriptで動画を表示
※未検証。
RasPi:MJPG-streamer動画配信で遊んでみた - Qiita
https://qiita.com/MuAuan/items/b3abd4cff2f39aa1f2d0
■トラブル
以下はパスを間違えて起動できない例。
$ sudo /usr/local/bin/mjpg_streamer -i "./input_uvc.so -f 30 -r 640x480 -d /dev/video0 -q 80" -o "output_http.so -p 8080 -w ./www"
MJPG Streamer Version: git rev: 85f89a8c321e799fabb1693c5d133f3fb48ee748
ERROR: could not find input plugin
Perhaps you want to adjust the search path with:
# export LD_LIBRARY_PATH=/path/to/plugin/folder
dlopen: ./input_uvc.so: cannot open shared object file: No such file or directory