-
Notifications
You must be signed in to change notification settings - Fork 4
/
mjpeg_test.sh
executable file
·54 lines (50 loc) · 971 Bytes
/
mjpeg_test.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#
# Motion JPEG test
#
# After running this shell script, open http://localhost:3000/mjpeg/ with
# Firefox. You will need the following in /etc/sighttpd/sighttpd.conf
# (or use the sighttpd-stdin-mjpeg.conf file, which will be installed
# in $prefix/share/sighttpd)
#
# -----
# Listen 3000
#
# <Stdin>
# Path "/mjpeg/"
# Type "multipart/x-mixed-replace; boundary=++++++++"
# </Stdin>
# -----
if [ $# -lt 1 ]; then
echo "Usage: $0 jpeg_file [...]"
exit 1;
fi
count=0
while [ $# -gt 0 ];
do
if [ ! -f $1 ]; then
echo "File '$1' not fonund."
else
FILE[$count]=$1
SIZE[$count]=`ls -l $1 | awk '{ print $5 }'`
((count++))
fi
shift;
done
PORT=3000
SIGHTTPD=sighttpd
BOUNDARY=++++++++
(
while true;
do
n=0
while [ $n -lt $count ];
do
printf "\r\n\r\n--%s\r\n" ${BOUNDARY}
printf "Content-type: image/jpeg\r\n"
printf "Content-length: %d\r\n\r\n" ${SIZE[$n]}
cat ${FILE[$n]}
((n++))
done;
done
) | ${SIGHTTPD} ${PORT}