Skip to content

Commit

Permalink
Merge pull request #78 from LuisMayo/avoid-reencoding
Browse files Browse the repository at this point in the history
Avoid reencoding
  • Loading branch information
LuisMayo authored Jun 18, 2022
2 parents 47d3af8 + 0b00493 commit 5f73e95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" 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.

4 changes: 2 additions & 2 deletions objection_engine/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion objection_engine/beans/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5f73e95

Please sign in to comment.