apt-get install lirc
sudo apt-get install usb-modeswitch
, /dev/modems/nova_091095493721000_1-1.5
cat /etc/udev/rules.d/52-ftdi.rules SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="sensors/ftdi_%s{serial}_%b" SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="1410", ATTRS{idProduct}=="6000", SYMLINK+="modems/nova_%s{serial}_%b"
import lirc import time import subprocess import os import signal import sys import RPi.GPIO as GPIO class Proc(object): def __init__(self, args): self.args = args self.proc = None def start(self): if self.proc != None: if self.proc.poll() == None: return self.proc = subprocess.Popen(self.args, shell=False, preexec_fn=os.setsid) #preexec_fn=os.setsid` def stop(self): if self.proc == None: return #self.proc.kill() try: os.killpg(os.getpgid(self.proc.pid), 15) except OSError as e: print e.strerror try: self.proc.terminate() except OSError as e: print e.strerror self.proc = None def is_live(self): if self.proc != None: if self.proc.poll() == None: return True self.stop() return False GPIO.setmode(GPIO.BCM) GPIO.setup(26, GPIO.OUT) GPIO.setup(12, GPIO.OUT) GPIO.setup(16, GPIO.OUT) GPIO.setup(20, GPIO.OUT) GPIO.output(26,False) GPIO.output(12,False) GPIO.output(16,False) GPIO.output(20,False) ppp = Proc(['./dial.sh']) video = Proc(['./video1.sh']) video2 = Proc(['./video2.sh']) video3 = Proc(['./video3.sh']) ws = Proc(['./webserver.sh']) ws.start() def terminate(): GPIO.cleanup() ppp.stop() video.stop() video2.stop() video3.stop() ws.stop() def signal_term_handler(signal, frame): print 'got SIGTERM' terminate() sys.exit(0) signal.signal(signal.SIGTERM, signal_term_handler) sockid = lirc.init("ctrl1", blocking = False) tac = False try: while True: codeIRs = lirc.nextcode() # print codeIR nocode = True for codeIR in codeIRs: nocode = False print codeIR, len(codeIR) if codeIR == "star": print "STAR DETECTED" if codeIR == "1": ppp.start() if codeIR == "2": ppp.stop() if codeIR == "3": subprocess.call("./notify.py") if codeIR == "4": video.start() if codeIR == "5": video.stop() if codeIR == "7": video2.start() if codeIR == "8": video2.stop() if codeIR == "6": video3.start() if codeIR == "9": video3.stop() tac = not tac GPIO.output(26,ppp.is_live() or (os.path.exists("/dev/modems/nova_091095493721000_1-1.5") and tac)) GPIO.output(12,video.is_live()) GPIO.output(16,video2.is_live() or (video3.is_live() and tac)) GPIO.output(20,ws.is_live()) if nocode: time.sleep(0.1) except KeyboardInterrupt: terminate() print "Good bye"
#!/bin/bash cd video python -m SimpleHTTPServer
#!/bin/bash route delete default wvdial
#!/bin/bash base="/home/pi/my/py/ir/" cd $base rm -fr video/* raspivid -n -ih -t 0 -ISO 800 -ex night -w 320 -h 240 -fps 30 -b 500000 -o - | \ ./ffmpeg -y \ -loglevel panic \ -i - \ -c:v copy \ -map 0 \ -f ssegment \ -segment_time 1 \ -segment_format mpegts \ -segment_list "$base/video/stream.m3u8" \ -segment_list_size 10 \ -segment_wrap 20 \ -segment_list_flags +live \ -segment_list_type m3u8 \ -segment_list_entry_prefix / \ "$base/video/%03d.ts"
#!/bin/bash raspivid -t 0 -h 240 -w 320 -fps 30 -hf -b 100000 -o - | nc -l 5001
nc 94.248.14.212 5001 | mplayer -fps 120 -cache 1024 -
$> cat video3.sh #!/bin/bash raspivid -t 0 -h 240 -w 320 -fps 25 -hf -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=0.0.0.0 port=5000
gst-launch-1.0 -v tcpclientsrc host=94.248.14.212 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false
Source: https://habr.com/ru/post/258377/
All Articles