PyObjC VideoToolbox Framework
This library provides Python wrappers for the macOS VideoToolbox framework, enabling access to its functionalities for video compression, decompression, and processing. It is part of the larger PyObjC project, which bridges Python and Objective-C, and typically sees releases aligned with macOS SDK updates.
Warnings
- breaking PyObjC 12.0 and later dropped support for Python 3.9.
- breaking PyObjC 11.0 and later dropped support for Python 3.8.
- breaking PyObjC 11.1 changed how `init` methods in Python subclasses interact with Objective-C's Automatic Reference Counting (ARC). PyObjC now correctly models that methods in the 'init' family steal a reference to self and return a new reference.
- gotcha Interaction between `__new__` and `__init__` in Python subclasses changed in PyObjC 10.3 and 10.3.1. While 10.3 removed support for calling `__init__` in some cases, 10.3.1 re-enabled it for classes with user-implemented `__new__`. However, if relying on PyObjC's default `__new__`, `__init__` might not be called.
- gotcha PyObjC's experimental support for free-threading (PEP 703) introduced in Python 3.13 is still evolving. Earlier PyObjC versions (e.g., 10.3) explicitly stated no support.
- gotcha As of PyObjC 10.1, `os.fspath(someURL)` will raise a `TypeError` for Cocoa `NSURL` (or `CFURLRef`) instances that do not refer to local filesystem paths.
Install
-
pip install pyobjc-framework-videotoolbox
Imports
- VideoToolbox
from VideoToolbox import VTCopyVideoEncoderList
Quickstart
import objc
from VideoToolbox import VTCopyVideoEncoderList
# Get a list of available video encoders
# VTCopyVideoEncoderList takes a CFDictionaryRef as an argument, or None for default
encoder_list = VTCopyVideoEncoderList(None)
if encoder_list:
print(f"Found {len(encoder_list)} video encoders:")
for encoder in encoder_list:
# encoder is an NSDictionary (bridged to Python dict)
print(f" - {encoder.get('kVTVideoEncoderComponentDisplayName', 'Unknown Encoder')}")
print(f" Type: {encoder.get('kVTVideoEncoderComponentType', 'Unknown')}")
else:
print("No video encoders found.")