class server: """Servidor""" ta = "" tv1 = "" tv2 = "" tv3 = "" tv4 = "" def __init__(self): self.ip_server = "192.168.1.128" self.portAudio = 5000 self.port1 = 5001 self.port2 = 5002 self.port3 = 5003 self.port4 = 5004 def configActividad(self): NombreActividad= datetime.now().strftime("%d-%m-%Y-%H-%M-%S") root = 'db/'+ NombreActividad os.makedirs(root, exist_ok=True) self.act = actividad(root) print("configured activity") def activate(self): self.ta = Audio(ipServer=self.ip_server, portAudio = self.portAudio, file = self.act.data["audioFile"], mg = mg, idAct = self.act.id) self.tv1 = Video(ipServer=self.ip_server, port = self.port1, file = self.act.data["video1File"]) self.tv2 = Video(ipServer=self.ip_server, port = self.port2, file = self.act.data["video2File"]) self.tv3 = Video(ipServer=self.ip_server, port = self.port3, file = self.act.data["video3File"]) self.tv4 = Video(ipServer=self.ip_server, port = self.port4, file = self.act.data["video4File"]) print("activated") def start(self): self.ta.start() self.tv1.start() self.tv2.start() self.tv3.start() self.tv4.start() print("listening") def record(self): self.ta.record() self.tv1.record() self.tv2.record() self.tv3.record() self.tv4.record() self.act.startRecording() print("recording") def finished(self): self.ta.finished() self.tv1.finished() self.tv2.finished() self.tv3.finished() self.tv4.finished() self.act.endRecording() print("finished") def processVideo(self): self.op = OPVideo(mg = mg) self.op.getKeyPointsVideo(input = self.act.data["video1File"], outputV = self.act.data["videoout1File"],idact = self.act.id,iduser=0) logging.debug("video1") self.op = OPVideo(mg = mg) self.op.getKeyPointsVideo(input = self.act.data["video2File"], outputV = self.act.data["videoout2File"],idact = self.act.id,iduser=1) logging.debug("video2") self.op = OPVideo(mg = mg) self.op.getKeyPointsVideo(input = self.act.data["video3File"], outputV = self.act.data["videoout3File"],idact = self.act.id,iduser=2) logging.debug("video3") self.op = OPVideo(mg = mg) self.op.getKeyPointsVideo(input = self.act.data["video4File"], outputV = self.act.data["videoout4File"],idact = self.act.id,iduser=3) logging.debug("video4") del self.op
mg=mg, idAct=data["id"]) tv1 = Video(ipServer=ip_server, port=port1, file=data["video1File"]) tv2 = Video(ipServer=ip_server, port=port2, file=data["video2File"]) tv3 = Video(ipServer=ip_server, port=port3, file=data["video3File"]) tv4 = Video(ipServer=ip_server, port=port4, file=data["video4File"]) print("video", flush=True) ta.start() tv1.start() tv2.start() tv3.start() tv4.start() print("start", flush=True) ta.record() tv1.record() tv2.record() tv3.record() tv4.record() print("record", flush=True) newvalues = {"$set": {"startRecording": datetime.today()}} mg.update_one("Activities", id=ObjectId(data["id"]), newvalues=newvalues)
from audio.audio import Audio import threading import logging from datetime import datetime import time if __name__ == '__main__': ip_server = "192.168.1.128" portAudio = 5000 output = "audio/outputTest.wav" audio = Audio(ipServer=ip_server, portAudio=portAudio, file=output, mode=False) audio.start() audio.record() time.sleep(20) audio.finished()