From e61a011bde1f0e8a7678e4b40e333d3f120b1f23 Mon Sep 17 00:00:00 2001 From: Luis Mayo Valbuena Date: Wed, 8 Jun 2022 21:47:51 +0200 Subject: [PATCH 1/3] Avoid reencoding if flag set --- objection_engine/anim.py | 4 ++-- objection_engine/beans/video.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/objection_engine/anim.py b/objection_engine/anim.py index 380c347..3b47782 100644 --- a/objection_engine/anim.py +++ b/objection_engine/anim.py @@ -380,8 +380,8 @@ def ace_attorney_anim(config: List[Dict], output_filename: str = "output.mp4", r textInput, audio, output_filename, - vcodec="libx264", - acodec="aac", + vcodec="copy" if os.getenv('OE_DIRECT_H264_ENCODING', 'false') == 'true' else "libx264", + acodec="copy", strict="experimental" ) try: diff --git a/objection_engine/beans/video.py b/objection_engine/beans/video.py index 2ca8b34..4c15766 100644 --- a/objection_engine/beans/video.py +++ b/objection_engine/beans/video.py @@ -18,7 +18,7 @@ def render(self, output_path: str = None): rnd_hash = random.getrandbits(64) output_path = f"tmp/{rnd_hash}.mp4" - fourcc = cv2.VideoWriter_fourcc(*"mp4v") + fourcc = cv2.VideoWriter_fourcc(*"h264") if os.getenv('OE_DIRECT_H264_ENCODING', 'false') == 'true' else cv2.VideoWriter_fourcc(*"mp4v") background = self.scenes[0].frames[0] if os.path.isfile(output_path): os.remove(output_path) From 5066da8ed2c84691e5e5192c64d4c74e38501c49 Mon Sep 17 00:00:00 2001 From: Luis Mayo Valbuena Date: Sat, 18 Jun 2022 00:49:15 +0200 Subject: [PATCH 2/3] readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index aa012b0..b7a2c52 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ The following environment variables are honored by objection_engine: - oe_bypass_sentiment: If on any value other than the empty string, the sentiment analysis is bypassed - oe_stats_server: If present, it will be used as the URL to post statistics to. The server responsible should be similar to https://github.com/LuisMayo/simple-server-counter - oe_polyglot_models: (docker only) If on polyglot model(s), the data for the model will be downloaded when starting the container. +- OE_DIRECT_H264_ENCODING: If true it ## Contributing Since this is a tiny project we don't have strict rules about contributions. Just open a Pull Request to fix any of the project issues or any improvement you have percieved on your own. Any contributions which improve or fix the project will be accepted as long as they don't deviate too much from the project objectives. If you have doubts about whether the PR would be accepted or not you can open an issue before coding to ask for my opinion. From 0b00493cffbe4667fad846aaf5809199bbb4add5 Mon Sep 17 00:00:00 2001 From: Luis Mayo Valbuena Date: Sat, 18 Jun 2022 17:28:18 +0200 Subject: [PATCH 3/3] Added info about h264 encoding --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7a2c52..ed70856 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ The following environment variables are honored by objection_engine: - oe_bypass_sentiment: If on any value other than the empty string, the sentiment analysis is bypassed - oe_stats_server: If present, it will be used as the URL to post statistics to. The server responsible should be similar to https://github.com/LuisMayo/simple-server-counter - oe_polyglot_models: (docker only) If on polyglot model(s), the data for the model will be downloaded when starting the container. -- OE_DIRECT_H264_ENCODING: If true it +- OE_DIRECT_H264_ENCODING: If "true" then it will directly encode the videos in H264 with OpenCV, instead of encoding in mp4v and re-encoding later. This is faster than the default, but it requires running on windows or having a self-compiled OpenCV build in your system. If you don't know what any of this means, don't enable it. ## Contributing Since this is a tiny project we don't have strict rules about contributions. Just open a Pull Request to fix any of the project issues or any improvement you have percieved on your own. Any contributions which improve or fix the project will be accepted as long as they don't deviate too much from the project objectives. If you have doubts about whether the PR would be accepted or not you can open an issue before coding to ask for my opinion.