summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/app/search/live.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/cli/app/search/live.py b/cli/app/search/live.py
index 8635b4c..8038e72 100644
--- a/cli/app/search/live.py
+++ b/cli/app/search/live.py
@@ -22,6 +22,7 @@ sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..
from rpc import CortexRPC
from app.search.params import timestamp
from app.utils.tf_utils import read_checkpoint
+from subprocess import Popen, PIPE
FPS = 25
@@ -410,13 +411,33 @@ class Listener:
interpolator.build()
self.rpc_client.send_status('processing', True)
tag = "biggan_" + timestamp()
- path_out = os.path.join(app_cfg.DIR_RESULTS, tag)
- os.makedirs(path_out, exist_ok=True)
+ # path_out = os.path.join(app_cfg.DIR_RESULTS, tag)
+ # os.makedirs(path_out, exist_ok=True)
gen_time_total = 0
to_pil_time_total = 0
save_time_total = 0
resize_time_total = 0
send_time_total = 0
+ p = Popen([
+ 'ffmpeg',
+ '-y',
+ '-f', 'image2pipe',
+ '-vcodec', 'png',
+ '-r', '25',
+ '-i', '-',
+
+ '-c:v', 'libx264',
+ '-preset', 'slow',
+ '-crf', '19',
+ '-vf', 'fps=25',
+ '-pix_fmt', 'yuv420p',
+ '-s', '512x512',
+
+ # '-vcodec', 'mpeg4',
+ # '-qscale', '5',
+ '-r', '25', '{}.mp4'.format(tag)
+ ], stdin=PIPE, stdout=PIPE)
+
for i in range(99999):
if i == 0:
print("Loading network...")
@@ -441,7 +462,8 @@ class Listener:
if out_img is not None:
save_time = time.time()
- out_img.save(os.path.join(path_out, "frame_{:05d}.png".format(i)), format='png', compression_level=3)
+ # out_img.save(os.path.join(path_out, "frame_{:05d}.png".format(i)), format='png', compression_level=3)
+ out_img.save(p.stdin, format='png', compression_level=3)
save_time_total += time.time() - save_time
resize_time = time.time()
@@ -459,5 +481,7 @@ class Listener:
send_time_total += time.time() - send_time
if (i % 100) == 0 or i == 1:
print("gen: {:2f}, pil: {:2f}, save: {:2f}, resize: {:2f}, send: {:2f}".format(gen_time_total / i, to_pil_time_total / i, save_time_total / i, resize_time_total / i, send_time_total / i))
+ p.stdin.close()
+ p.wait()
self.rpc_client.send_status('processing', False)
self.sess.close()