92 lines
1.9 KiB
Python
92 lines
1.9 KiB
Python
#!/usr/bin/python
|
|
#
|
|
# really crappy stream viewer
|
|
|
|
import subprocess
|
|
import time
|
|
|
|
# constants and crap
|
|
|
|
# location of save directory
|
|
SAVE_DIRECTORY = "/home/dburr/tmp"
|
|
|
|
# size of screen
|
|
SCREEN_WIDTH = 1920
|
|
SCREEN_HEIGHT = 1080
|
|
|
|
# size of video
|
|
VIDEO_WIDTH = 320
|
|
VIDEO_HEIGHT = 200
|
|
|
|
# start position
|
|
START_X = 80
|
|
START_Y = 40
|
|
|
|
# offsets
|
|
X_OFFSET = 2
|
|
Y_OFFSET = 2
|
|
|
|
NAMES = []
|
|
MACS = []
|
|
IPS = []
|
|
PIDS = []
|
|
|
|
def startProcess(cmd):
|
|
devnull = open('/dev/null', 'w')
|
|
process = subprocess.Popen(cmd, stdin=None, stdout=devnull, stderr=devnull, shell=False)
|
|
return process.pid
|
|
|
|
file = open("CAMS", "r")
|
|
i = 0
|
|
|
|
for line in file:
|
|
stripped_line = line.rstrip()
|
|
if not stripped_line.startswith("#"):
|
|
split_string = stripped_line.split('|')
|
|
print "CAMERA: %s IP: %s MAC: %s" % (split_string[2], split_string[1], split_string[0])
|
|
NAMES.append(split_string[2])
|
|
MACS.append(split_string[0])
|
|
IPS.append(split_string[1])
|
|
|
|
x = START_X
|
|
y = START_Y
|
|
|
|
for idx, val in enumerate(NAMES):
|
|
print "starting cam " + NAMES[idx] + " at url " + IPS[idx] + " at (" + str(x) + "," + str(y) + ")"
|
|
#command = ["/usr/bin/cvlc", "cvlc", "--width", "320", "--height", "240", "--zoom", "0.3", "--video-x", str(x), "--video-y", str(y), "--video-title=" + NAMES[idx], "foo"]
|
|
command = ["/usr/bin/cvlc", "cvlc", "--width", "320", "--height", "240", "--zoom", "0.3", "--video-x", str(x), "--video-y", str(y), "--video-title=" + NAMES[idx], "http://"+IPS[idx]+":8080/"]
|
|
pid = startProcess(command)
|
|
print "started with pid " + str(pid)
|
|
time.sleep(2)
|
|
command = ["/usr/bin/wmctrl", "wmctrl", "-Fr", NAMES[idx], "-e", "0,"+str(x)+","+str(y)+",320,240"]
|
|
nada = startProcess(command)
|
|
#sleep 1;wmctrl -Fr "${NAMES[$i]}" -e "0,$x,$y,320,240"
|
|
x = x + VIDEO_WIDTH + X_OFFSET
|
|
if x > SCREEN_WIDTH - (VIDEO_WIDTH + X_OFFSET):
|
|
x = START_X
|
|
y = y + VIDEO_HEIGHT + Y_OFFSET
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|