From f898644a3cfe1b25fed31af090edf64b964efa03 Mon Sep 17 00:00:00 2001 From: Mehmet Mert Yildiran Date: Wed, 31 Oct 2018 11:16:18 +0300 Subject: [PATCH] Add point to point streaming from ffmpeg to mplayer via TCP --- scene/scene.py | 9 ++++++++- test1.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scene/scene.py b/scene/scene.py index f116cf52..5b65b9f0 100644 --- a/scene/scene.py +++ b/scene/scene.py @@ -624,13 +624,20 @@ class Scene(Container): '-vcodec', 'libx264', '-pix_fmt', 'yuv420p', ] - command += [temp_file_path] + if self.is_live_streaming: + command += ['-f', 'mpegts'] + command += ['tcp://127.0.0.1:2000'] + else: + command += [temp_file_path] + print(' '.join(command)) # self.writing_process = sp.Popen(command, stdin=sp.PIPE, shell=True) self.writing_process = sp.Popen(command, stdin=sp.PIPE) def close_movie_pipe(self): self.writing_process.stdin.close() self.writing_process.wait() + if self.is_live_streaming: + return True if os.name == 'nt': shutil.move(*self.args_to_rename_file) else: diff --git a/test1.py b/test1.py index ab2e173b..169eb341 100644 --- a/test1.py +++ b/test1.py @@ -16,3 +16,7 @@ manim.play(GrowFromCenter(square)) manim.play(Transform(square,triangle)) manim.close_movie_pipe() + +# mplayer -cache 8092 ffmpeg://tcp://127.0.0.1:2000?listen +# for listening the stream +# start mplayer before running this script