Commit 87751f875797482a6572eccaf46400729ccbfc4c

Authored by Wesnydy Ribeiro
1 parent 9502ba91

Response to queue filename and filesize

Showing 1 changed file with 12 additions and 2 deletions   Show diff stats
core/renderer.py
@@ -12,6 +12,7 @@ Author: Wesnydy Lima Ribeiro @@ -12,6 +12,7 @@ Author: Wesnydy Lima Ribeiro
12 E-Mail: wesnydy@lavid.ufpb.br 12 E-Mail: wesnydy@lavid.ufpb.br
13 """ 13 """
14 14
  15 +import json
15 import os 16 import os
16 import pika 17 import pika
17 import PikaManager 18 import PikaManager
@@ -43,6 +44,8 @@ PATH_SCREENS = "/storage/frames/" @@ -43,6 +44,8 @@ PATH_SCREENS = "/storage/frames/"
43 44
44 # Status of renderer to process new requests. Answer one request at a time. 45 # Status of renderer to process new requests. Answer one request at a time.
45 worker_available = True 46 worker_available = True
  47 +# Path of libras video.
  48 +libras_video = None
46 # pyvirtualdisplay instance 49 # pyvirtualdisplay instance
47 display = None 50 display = None
48 # ffmpeg process instance 51 # ffmpeg process instance
@@ -88,7 +91,7 @@ def start_ffmpeg(id): @@ -88,7 +91,7 @@ def start_ffmpeg(id):
88 id : string 91 id : string
89 Identification of request. 92 Identification of request.
90 """ 93 """
91 - global ffmpeg, display 94 + global ffmpeg, display, libras_video
92 # logger.info("Starting ffmpeg") 95 # logger.info("Starting ffmpeg")
93 libras_video = os.path.join(PATH_LIBRAS, id + ".mp4") 96 libras_video = os.path.join(PATH_LIBRAS, id + ".mp4")
94 ffmpeg = subprocess.Popen( 97 ffmpeg = subprocess.Popen(
@@ -164,7 +167,14 @@ def run(ch, method, properties, body): @@ -164,7 +167,14 @@ def run(ch, method, properties, body):
164 start_new_thread(send_to_video_creator, (properties.correlation_id, body)) 167 start_new_thread(send_to_video_creator, (properties.correlation_id, body))
165 start_video_creator(properties.correlation_id) 168 start_video_creator(properties.correlation_id)
166 169
167 - body = properties.correlation_id + ".mp4" 170 + try:
  171 + filesize = os.path.getsize(libras_video)
  172 + except:
  173 + filesize = 0
  174 +
  175 + body = {"file": properties.correlation_id+".mp4", "size": filesize}
  176 + json.dumps(body)
  177 +
168 manager.send_to_queue("videos", body, properties) 178 manager.send_to_queue("videos", body, properties)
169 179
170 clean(properties.correlation_id) 180 clean(properties.correlation_id)