티스토리 뷰
728x90
출처
- How to build and run MJPG-Streamer on the Raspberry Pi
- 라즈베리파이 파이카메라 활용강좌 : 웹 스트리밍(Mjpg-Stream)
- fishkingsin/mjpg_streamer.sh
MJPG streamer 컴파일 관련 라이브러리 설치
pi@raspberrypi:~$ sudo apt update
pi@raspberrypi:~$ sudo apt upgrade
pi@raspberrypi:~$ sudo apt-get install cmake libjpeg9-dev imagemagick libv4l-dev libgphoto2-dev
MJPG streamer 소스 다운로드, 컴파일, 설치
pi@raspberrypi:~$ git clone https://github.com/jacksonliam/mjpg-streamer.git
pi@raspberrypi:~$ cd mjpg-streamer/mjpg-streamer-experimental/
pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental$ make
pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental$ sudo make install
LD_LIBRARY_PATH 경로 추가
pi@raspberrypi:~$ echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/mjpg-streamer" | sudo tee -a /etc/profile
MJPG Streamer 수동 실행
출처 : MJPG Streamer configuration
pi@raspberrypi:~$ mjpg_streamer -i "input_raspicam.so -x 640 -y 480 -fps 10 -rot 180 -ex night" --output "output_http.so -w /usr/local/share/mjpg-streamer/www --port 4998"
MJPG Streamer Version: git rev: 85f89a8c321e799fabb1693c5d133f3fb48ee748
i: fps.............: 10
i: resolution........: 640 x 480
i: camera parameters..............:
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'night', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 180, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
o: www-folder-path......: /usr/local/share/mjpg-streamer/www/
o: HTTP TCP port........: 4998
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: enabled
i: Starting Camera
Encoder Buffer Size 81920
서비스등록
pi@raspberrypi:~$ sudo vi /etc/init.d/mjpg_streamer
mjpg_streamer 파일 내용
#!/bin/bash
# /etc/init.d/mjpg_streamer.sh
# v0.2 phillips321.co.uk
### BEGIN INIT INFO
# Provides: mjpg_streamer.sh
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mjpg_streamer for webcam
# Description: Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO
#
export width=640
export height=480
export bitrate=10
export SHUTDOWN_WAIT=2
if [ -n "$2" ]; then
width=$2
fi
if [ -n "$3" ]; then
height=$3
fi
if [ -n "$4" ]; then
bitrate=$4
fi
export LD_MJPG_STREAMER=/usr/local/lib/mjpg-streamer
f_message(){
echo "[+] $1"
}
mjpg_streamer_pid() {
echo `ps aux | grep mjpg-streamer | grep -v grep | awk '{ print $2 }'`
}
start() {
pid=$(mjpg_streamer_pid)
if [ -n "$pid" ]
then
echo "mjpg_streamer is already running (pid: $pid)"
else
# Start mjpg_streamer
f_message "Starting mjpg_streamer"
mjpg_streamer -b -i "$LD_MJPG_STREAMER/input_uvc.so -r "$width"x"$height" -f $bitrate -y" -o "$LD_MJPG_STREAMER/output_http.so -p 4998 -w /usr/local/share/mjpg-streamer/www"
sleep 2
f_message "mjpg_streamer started"
fi
return 0
}
stop() {
pid=$(mjpg_streamer_pid)
if [ -n "$pid" ]
then
f_message "Stopping mjpg_streamer..."
kill -9 $pid
let kwait=$SHUTDOWN_WAIT
let count=0;
until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
do
echo -n -e "\nwaiting for processes to exit";
sleep 1
let count=$count+1;
done
if [ $count -gt $kwait ]; then
echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n"
kill -9 $pid
fi
else
echo "mjpg_streamer is not running"
fi
return 0
}
# Carry out specific functions when asked to by the system
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
resolution)
resolution=`ps axu | grep mjpg-streamer | grep -v grep | awk '{ print $16 }'`
if [ -n "$resolution" ];
then
echo "${resolution}"
else
echo "0x0"
fi
;;
status)
pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk '{print $1}' | head -n 1`
if [ -n "$pid" ];
then
f_message "mjpg_streamer is running with pid ${pid}"
f_message "mjpg_streamer was started with the following command line"
cat /proc/${pid}/cmdline ; echo ""
else
f_message "Could not find mjpg_streamer running"
fi
;;
*)
f_message "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
등록
pi@raspberrypi:~$ sudo chmod u+x /etc/init.d/mjpg_streamer
pi@raspberrypi:~$ sudo update-rc.d mjpg_streamer defaults
서비스 실행 및 실행 확인
pi@raspberrypi:~$ sudo service mjpg_streamer start
pi@raspberrypi:~$ sudo service mjpg_streamer status
● mjpg_streamer.service - LSB: mjpg_streamer for webcam
Loaded: loaded (/etc/init.d/mjpg_streamer; generated)
Active: active (running) since Fri 2020-10-02 18:06:59 BST; 16s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 3 (limit: 1942)
CGroup: /system.slice/mjpg_streamer.service
└─4761 mjpg_streamer -b -i /usr/local/lib/mjpg-streamer/input_uvc.so -r 640x480 -f 10 -y -o /usr/local/lib/mjpg-streamer/output_http.so -p 4998 -w /usr/local/share/mjpg-streamer/www
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: TV-Norm...........: DEFAULT
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: www-folder-path......: /usr/local/share/mjpg-streamer/www/
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: HTTP TCP port........: 4998
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: HTTP Listen Address..: (null)
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: username:password....: disabled
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: commands.............: enabled
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: starting input plugin /usr/local/lib/mjpg-streamer/input_uvc.so
Oct 02 18:06:57 raspberrypi mjpg_streamer[4761]: MJPG-streamer [4761]: starting output plugin: /usr/local/lib/mjpg-streamer/output_http.so (ID: 00)
Oct 02 18:06:59 raspberrypi mjpg_streamer[4751]: [+] mjpg_streamer started
Oct 02 18:06:59 raspberrypi systemd[1]: Started LSB: mjpg_streamer for webcam.
확인
GPU 매모리 늘리기
pi@raspberrypi:~ $ sudo raspi-config
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- MySQL
- 일본여행
- 레이싱모델 익스트림 포토 페스티벌
- Delphi Tip
- NDK
- koba2010
- oracle
- android
- Spring
- ffmpeg
- 송주경
- 지스타2007
- SAS
- 튜닝쇼 2008
- KOBA
- flex
- Xcode
- BPI-M4
- Spring MVC
- 동경
- 전예희
- ubuntu
- ble
- Mac
- JavaScript
- 서울오토살롱
- Delphi
- Linux
- Java
- sas2009
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함