Created
November 13, 2023 13:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | |
else: | |
path = ffmpeg_bin | |
self.launch_context.env["PATH"] = path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on AYON discord discussion here