pyi_rth_gstreamer.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-2023, PyInstaller Development Team.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: Apache-2.0
  10. #-----------------------------------------------------------------------------
  11. def _pyi_rthook():
  12. import os
  13. import sys
  14. # Without this environment variable set to 'no' importing 'gst' causes 100% CPU load. (Tested on macOS.)
  15. os.environ['GST_REGISTRY_FORK'] = 'no'
  16. gst_plugin_paths = [sys._MEIPASS, os.path.join(sys._MEIPASS, 'gst-plugins')]
  17. os.environ['GST_PLUGIN_PATH'] = os.pathsep.join(gst_plugin_paths)
  18. # Prevent permission issues on Windows
  19. os.environ['GST_REGISTRY'] = os.path.join(sys._MEIPASS, 'registry.bin')
  20. # Only use packaged plugins to prevent GStreamer from crashing when it finds plugins from another version which are
  21. # installed system wide.
  22. os.environ['GST_PLUGIN_SYSTEM_PATH'] = ''
  23. _pyi_rthook()
  24. del _pyi_rthook