Skip to content

Instantly share code, notes, and snippets.

Created November 13, 2023 13:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save BigRoy/f9796f8cb5020944dbdf7fafd6935652 to your computer and use it in GitHub Desktop.
Example AYON / OpenPype PreLaunchHook to insert Ayon's FFMPEG to PATH environment variable on launch of applications
import os
from openpype.lib.applications import PreLaunchHook, LaunchTypes
from openpype.lib.vendor_bin_utils import get_ffmpeg_tool_path
class AddFFMPEGToPath(PreLaunchHook):
"""Insert Ayon FFMPEG in `PATH`"""
# Should be as last hook because must change launch arguments to string
app_groups = {"*"}
platforms = {"*"}
launch_types = {LaunchTypes.local}
def execute(self):
path = self.launch_context.env.get("PATH")
ffmpeg = get_ffmpeg_tool_path()
ffmpeg_bin = os.path.dirname(ffmpeg)
if path:
path = os.pathsep.join([ffmpeg_bin, path])
path = ffmpeg_bin
self.launch_context.env["PATH"] = path
Copy link

BigRoy commented Nov 13, 2023

Based on AYON discord discussion here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment