2019/12/03

페어라인 테니스 방송 NVR 장비 개발을 위한 연구노트.

IP 카메라 및 NVR
buntu Server 18.04
헤드리스
브라우저(크롬 등)을 이용해 인터넷을 브라우징 할 때 기본적으로 창이 뜨고 HTML파일을 불러오고, CSS파일을 불러와
어떤 내용을 화면에 그러야 할지 계산을 하는 작업을 브라우저가 자동으로 진행해줍니다.
하지만 이와같은 방식을 사용할 경우 사용하는 운영체제에 따라 크롬이 실행이 될 수도,
실행이 되지 않을 수도 있습니다.
예를들어 우분투 서버와 같은 OS에서는 ‘화면’ 자체가 존재하지 않기 때문에 일반적인 방식으로는 크롬을 사용할 수 없습니다.
이를 해결해 주는 방식이 바로 Headless 모드입니다.
브라우저 창을 실제로 운영체제의 ‘창’으로 띄우지 않고 대신 화면을 그려주는 작업(렌더링)을 가상으로 진행해주는 방법으로,
실제 브라우저와 동일하게 동작하지만 창은 뜨지 않는 방식으로 동작할 수 있습니다.

※ 플렉스(PLEX)서버는 멀디 미디어 공유 및 라이브러리 어플리케이션이다.
서버에 어플을 다운받으면 메타 데이터를 이용한 라이브러리 환경을 구축해주고 다양한 플랫폼에서 이용 가능하다.
쉽게 말하면 개인의 nas 서버를 넷플릭스나 IPTV처럼 이용가능하게 만들어주는 클라우드 미디어 서비스 플랫품이다.
물론 사진과 음악도 스트리밍이 가능하지만 대부분 유저들은 동영상 스트리밍으로 활용되고 있다.
무료로 이용할 수 있지만, Plex Sync, Cloud Sync, Camera Upload, Trailers & Extras, Free Apps, Multi-User Control 등
핵심기능이 들어간 프리미엄 패스가 있다.
가격은 한달에 3.99달러, 1년에 29.99달러, 평생, 74.99달러. 가끔 블프 같은 때 세일을 하기도 한다. = wiki 백과

오픈소스 카메라
https://support.wyzecam.com/hc/en-us/articles/360026245231-Wyze-Cam-RTSP
https://support.wyzecam.com/hc/en-us/articles/360024852172
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks

IP 카메라 사용 소프트웨어
motionEyeOS
VLC (cvlc)
UV4L
UV4L 스 트리머
v4l2
OMXPlayer

IP 카메라로서의 MOTIONEYEOS

1. VLC (래피 비드 포함)
PI Zero W IP 카메라 실시간 명령어.
raspivid -o - -t 0 -w 1280 -h 720 -fps 20 -b 250000 | cvlc -vvv stream:///dev/stdin --sout '#rtp{access=udp,sdp=rtsp://:8554/unicast}' :demux=h264

v4l2 드라이버가있는 VLC 명령어.
cvlc -vvv v4l2:///dev/video0 --v4l2-width 1280 --v4l2-height 720 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=0.0.0.0:8554}' :demux=264

스트림 트랜스 코딩 명령어.
cvlc -vvv v4l2:///dev/video0 --sout '#transcode{vcodec=mp2v,vb=800,acodec=none}:rtp{sdp=rtsp://:8554/}'

-o - causes the output to be written to stdout
-t 0 sets the timeout to disabled
-n stops the video being previewed (remove if you want to see the video on the HDMI output?)
-w width
-h height
-fps framerate
-b bitrate

cvlc는 콘솔 vlc 플레이어
-vvv이며 인수는
-sout 에서 스트림을 가져올 위치를 지정하고 인수는 스트림을 출력 할 위치를 지정합니다.

스트림에 HTTP 또는 RTSP 프로토콜을 지정할 수 있습니다.
https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/
https://raspberry-projects.com/pi/pi-hardware/raspberry-pi-camera/streaming-video-using-vlc-player
https://raspberrypi.stackexchange.com/questions/23182/how-to-stream-video-from-raspberry-pi-camera-and-watch-it-live

2. UV4L
https://www.instructables.com/id/Raspberry-Pi-Video-Streaming/

curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add -

저장소 추가
sudo nano /etc/apt/sources.list deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main
sudo apt-get update
sudo apt-get install uv4l uv4l-raspicam

드라이버 선택
sudo apt-get install uv4l-raspicam-extras

사요하고 싶은 드라이버 선택해 사용.
sudo service uv4l_raspicam restart

모듈테스트
uv4l --driver raspicam --auto-video_nr --width 640 --height 480 --encoding jpeg

3. OMXPLAYER
omxplayer 또는 VLC (cvlc)를 사용할 수 있습니다.

https://github.com/popcornmix/omxplayer

omxplayer rtsp://12.34.56.78/live 사용.

HDMI 출력
omxplayer -o local rtsp://192.168.3.100:8554/live

4. V4L2RTSPSERVER
https://github.com/mpromonet/v4l2rtspserver

make 및 cmake가 설치되어 있어야합니다.
sudo apt-get install cmake liblog4cpp5-dev libv4l-dev
git clone https://github.com/mpromonet/v4l2rtspserver.git
cd v4l2rtspserver/
cmake .
make
sudo make install

사용 명령어.
v4l2rtspserver -F15 -H 972 -W1296 -P 8555 /dev/video0

sudo modprobe bcm2835-v4l2
cvlc v4l2:///dev/video0 --v4l2-width 1920 --v4l2-height 1080 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=0.0.0.0:12345}'

4.1 서비스 구축
sudo cp test_service.sh /usr/bin/streamrtsp.sh
sudo chmod +x /usr/bin/streamrtsp.sh

데몬 파일 작성
sudo vi /lib/systemd/system/streamrtsp.service
[Unit]
Description=Stream an RTSP IP Camera feed.

[Service]
Type=simple
ExecStart=/bin/bash /usr/bin/streamrtsp.sh

[Install]
WantedBy=multi-user.target

데몬 파일 등록
sudo cp streamrtsp.service /etc/systemd/system/streamrtsp.service
sudo chmod 644 /etc/systemd/system/streamrtsp.service

데몬 활성화
sudo systemctl enable streamrtsp

데몬 시작.
sudo start streamrtsp

5 NVR 기능 없음.
5.1 NVR 오픈 소스 검색
ZONEMINDER
KERBEROS.IO
SHINOBI

6. NVR SHINOBI 결정.
6.1 다운로드
sudo bash <(curl -s https://gitlab.com/Shinobi-Systems/Shinobi-Installer/raw/master/shinobi-install.sh)

다운로드 완료 되면, 웹 브라우저에서 다음 URL 로그인 입력
http://yourraspberrypiIP:8080
http://raspberrypi.local

Default Superuser : admin@shinobi.video
Default Password : admin

관리자 URL 주소
http://yourraspberrypiIP:8080/super
http://raspberrypi.local/super

6.2 공식 문서
https://shinobi.video/docs/start

7. 모션
https://motion-project.github.io/

모션 가능 이벤트에서 비디오 또는 사진 생성 및 저장, 녹화 예약, 캡처, 라이브 스트림을 볼 수있다.
명령 줄 기반.
모든 구성 및 설정은 구성 파일로 수행된다.

8. MOTIONEYE/MOTIONEYEOS
motionEye 선택
PI 사전 빌드 파일.
https://github.com/ccrisan/motioneye/wiki/Install-On-Ubuntu

컴파일 환경
https://github.com/ccrisan/motioneye/wiki/Install-On-Raspbian

sudo apt update
sudo apt upgrade

sudo apt install ffmpeg

sudo apt install libmariadb3 libmicrohttpd12 libpq5

댓글 없음:

댓글 쓰기