ghans, I'll keep that in mind - I've got another issue to resolve in the meantime though!
As my project will be exhibited at both my degree show and an exhibition I decided to download the webcam feeds and play them in a matter that seems live, allowing me to circumvent any issues with internet connections or broken cameras. I am using RFID tags to switch between two webcam feeds through a Python script; the starting point of the videos are determined by how long the script has been running.
For some reason my script only plays the videos with a delay when done through the Python interface; using the start-up command line to call the script always plays the videos from the beginning. Am I using commands or functions that don't work with the start-up command line? What else could be the cause of this?
Code: Select all
#!/usr/bin/env python
# Allows script to run by itself
# RFID webcam viewer written by Rory Findlater
from subprocess import Popen, PIPE, STDOUT, call # imports needed modules
import time
import math
prog_start = time.clock
pipe = open(‘/dev/ttyUSB0’,’r’) # opens a pipe for USB to read
while 1: # loops until initial stream selected
if “4” in pipe.read(1): # looks in pipe for value in RFID code
call([‘clear’, ‘>’, ‘/dev/tty1’]) # clears screen so no text shows during video transition
Playtembe = Popen([‘omxplayer’, ‘/home/pi/Tembe.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
Playtembe0N = 1
break
# Turn Tembe on
elif “7” in pipe.read(1):
call([‘clear’, ‘>’, ‘/dev/tty1’])
Playidube = Popen([‘omxplayer’, ‘/home/pi/Idube.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
PlayidubeON = 1
break
# Turn Idube on
while 1: # loop for selecting streams
if “4” in pipe.read(1) and PlayidubeON == 1:
Playidube.communicate(input=’q’)[0]
PlayidubeON = 0
# Turn Idube off
CurrentTimeRaw = time.clock() – prog_start
CurrentTime3 = CurrentTimeRaw / 3
Current Time = str(math.cell(CurrentTime3 *100))
call([‘clear’, ‘>’, ‘/dev/tty1’])
Playtembe = Popen([‘omxplayer’, ‘/home/pi/Tembe.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
Playtembe0N = 1
# Turn Tembe on
elif “7” in pipe.read(1) and PlaytembeON == 1:
Playtembe.communicate(input=’q’)[0]
PlaytembeON = 0
# Turn Tembe off
CurrentTimeRaw = time.clock() – prog_start
CurrentTime3 = CurrentTimeRaw / 3
Current Time = str(math.cell(CurrentTime3 *100))
call([‘clear’, ‘>’, ‘/dev/tty1’])
PlayIdube = Popen([‘omxplayer’, ‘/home/pi/Idube.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
PlayIdube0N = 1
# Turn Idube on