diff --git a/core/extractor.py b/core/extractor.py index 845bb4b..f05c94d 100755 --- a/core/extractor.py +++ b/core/extractor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- """ @@ -44,9 +44,6 @@ logger.addHandler(ch) manager = PikaManager.PikaManager("150.165.205.10", "test", "test") -#conn_send = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',heartbeat_interval=0)) -#conn_receive = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',heartbeat_interval=0)) - def run(ch, method, properties, body): """ Execute the worker. @@ -91,7 +88,7 @@ def run(ch, method, properties, body): body['pts'] = -1 body['index'] = index #Number of subtitle extracted - logger.info(str(index-1) + " Legendas extraídas") + logger.info(str(index-1) + " Legendas extraídas com sucesso") # Clean temporary file logger.info("Removendo arquivo temporário") os.remove(filename) diff --git a/core/mixer.py b/core/mixer.py index 5592270..735996e 100755 --- a/core/mixer.py +++ b/core/mixer.py @@ -26,7 +26,7 @@ from thread import start_new_thread from time import sleep from urllib import urlretrieve -PATH_VIDEO="/home/caiomcg/videos/" +PATH_MIXED_VIDEO = os.getenv("VLIBRAS_VIDEO_MIXED") logger = logging.getLogger('mixer') logger.setLevel(logging.DEBUG) @@ -44,9 +44,6 @@ ch.setFormatter(formatter) logger.addHandler(fh) logger.addHandler(ch) -#conn_send = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',heartbeat_interval=0)) -#conn_receive = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',heartbeat_interval=0)) - manager = PikaManager.PikaManager("150.165.205.10", "test", "test") def main_video_height(main_video): @@ -180,16 +177,15 @@ def run(ch, method, properties, body): # -Vf param filter_graph = ','.join([movie, scale, 'setpts=PTS-STARTPTS', overlay]) # Generates the output file path - mixed_video = os.path.join(PATH_VIDEO, properties.correlation_id.encode("utf-8")+".mp4") + mixed_video = os.path.join(PATH_MIXED_VIDEO, properties.correlation_id.encode("utf-8")+".mp4") # Mix videos using ffmpeg - print ("Mixing videos...",) + print ("Mixing videos...") logger.info("Mixando o vídeo original com a janela de libras") try: call( ['ffmpeg', '-v', 'error', '-i', main_video, '-y', '-vf', filter_graph, '-qscale', '0', '-strict', 'experimental', '-vcodec', 'libx264', '-preset', 'fast', '-r', '30', '-threads', '8', mixed_video], shell=False) - print ("Sucess") logger.info("Mixagem bem sucedida") except OSError as ex: logger.error("Mixagem mal sucedida") @@ -205,6 +201,17 @@ def run(ch, method, properties, body): manager.send_to_queue("videos", body, properties) print ("Success") +def keep_alive(conn_send, conn_receive): + while True: + sleep(30) + try: + conn_send.process_data_events() + conn_receive.process_data_events() + except: + continue + +start_new_thread(keep_alive, (manager.get_conn_send(), manager.get_conn_receive())) + # Starts listening print("Mixer listening...") while True: -- libgit2 0.21.2