PyObjC CoreMediaIO Framework
PyObjC-framework-CoreMediaIO provides Python wrappers for the CoreMediaIO framework on macOS, allowing Python applications to interact with system audio and video I/O devices. This library is part of the larger PyObjC project, which frequently updates its framework bindings in conjunction with new macOS SDK releases to ensure compatibility and expose new APIs.
Warnings
- breaking PyObjC frequently drops support for older Python versions. PyObjC 12.0 dropped support for Python 3.9; PyObjC 11.0 dropped support for Python 3.8. Always check `requires_python` metadata or release notes for compatibility.
- breaking In PyObjC 10.3, the ability to call `__init__` when a Python user class implemented `__new__` was initially removed, then partially reintroduced in 10.3.1. Code relying on `__new__` provided by PyObjC still cannot use `__init__`.
- breaking PyObjC 11.1 aligned its core bridge with `clang`'s Automatic Reference Counting (ARC) documentation for Objective-C initializer methods ('init' family). These methods now correctly steal a reference to `self` and return a new reference, which may alter reference counting behavior in some existing code, particularly with `[NSObject alloc]` proxies.
- breaking Starting with PyObjC 12.0, the `AVFAudio` framework was split into a separate top-level package (`AVFAudio`) instead of being merged into `AVFoundation`. While still included in the `pyobjc-framework-AVFoundation` distribution, direct imports must be updated.
- breaking The `IMServicePlugIn` framework bindings were removed in PyObjC 10.0, as the underlying framework was deprecated by Apple in macOS 10.13 and completely removed in macOS 14.
Install
-
pip install pyobjc-framework-coremediaio
Imports
- CoreMediaIO
import CoreMediaIO
- kCMIOObjectSystemObject
from CoreMediaIO import kCMIOObjectSystemObject
Quickstart
import CoreMediaIO
import os
# CoreMediaIO is a low-level C API framework, primarily dealing with constants,
# functions, and structs. This quickstart demonstrates importing the framework
# and accessing a fundamental system object constant to confirm setup.
# Check if the kCMIOObjectSystemObject constant is available
if hasattr(CoreMediaIO, 'kCMIOObjectSystemObject'):
system_object_id = CoreMediaIO.kCMIOObjectSystemObject
print(f"CoreMediaIO.kCMIOObjectSystemObject found: {system_object_id}")
else:
print("CoreMediaIO.kCMIOObjectSystemObject not found, framework might not be fully loaded or API changed.")
# Note: More complex interactions with CoreMediaIO (e.g., enumerating devices,
# getting property data) typically involve Objective-C C-style function calls
# requiring knowledge of `objc` bridge types (like pointers and structs).
# Refer to Apple's CoreMediaIO documentation and PyObjC examples for advanced usage.