pylibairplay
An AirPlay screen-mirroring receiver in pure Python. No GStreamer, no external receiver app, no C build step. It advertises itself over mDNS, pairs with an iPhone or iPad, decrypts the mirror stream and hands your code H.264 access units to decode however you like.
import asyncio
from pylibairplay import Receiver
async def main():
rx = Receiver(name="My Screen")
rx.on_video = lambda au: ... # au.data: Annex-B bytes; au.codec, au.pts, au.keyframe
rx.on_session = lambda info: print("connected:", info.device_name, info.width, info.height)
rx.on_end = lambda reason: print("ended:", reason)
await rx.serve()
asyncio.run(main())
au.data is an Annex-B H.264 access unit (SPS/PPS prepended on keyframes), ready for any
decoder such as PyAV.
Install
uv add "pylibairplay[net]" # or: pip install "pylibairplay[net]"
The net extra pulls in zeroconf (mDNS) and cryptography. Decoding is left to you, which
keeps the core dependency-light. To mirror from a modern iPhone with route B below, also add the
fairplay extra (unicorn, lief, capstone): pylibairplay[net,fairplay].
Authentication: pick a route
Modern iOS only mirrors to a receiver that can prove it is licensed. pylibairplay supports two ways to satisfy that, and which one you use is the main decision when adopting the library.
| A. Your own MFi certificate | B. FairPlay emulation | |
|---|---|---|
| Protocol | AirPlay 2 (transient / PIN pairing) | Legacy AirPlay 1 /fp-setup |
| You supply | An Apple MFi certificate and a way to sign with its key | Apple FairPlay binaries extracted from firmware you obtained |
| Redistributable | Yes — nothing Apple-owned ships | No — machine-local interop tooling |
| Startup | Instant | ~35 s emulator warm-up |
| Status | Implemented, not yet validated on a device | Working end-to-end on iOS 26 |
A. MFi certificate
If you are a licensed MFi developer, hand the receiver your certificate and a signer:
from pylibairplay import MFiCredentials, Receiver
creds = MFiCredentials.from_pem_files("mfi_cert.pem", "mfi_key.pem") # RSA-1024 or EC key
# or, if the key lives in an authentication chip / HSM:
creds = MFiCredentials(certificate=cert_der, sign=lambda challenge: chip.sign(challenge))
rx = Receiver(name="My Screen", mfi=creds)
From the command line: python -m pylibairplay.receiver --mfi-cert cert.pem --mfi-key key.pem.
pylibairplay does not provide or generate certificates.
B. FairPlay emulation
FairPlay is a whitebox that can't be reimplemented in portable code, so this route runs Apple's own code from your own device firmware under a local emulator. Nothing from Apple is shipped or committed.
# Extract the four dylibs for your device model with ipsw (https://github.com/blacktop/ipsw):
ipsw download ipsw --device <your-model> --latest
ipsw extract --dyld --dyld-arch arm64e <ipsw file> -o fw
ipsw dyld extract fw/*/dyld_shared_cache_arm64e -o fpdir \
AirPlayReceiver AirPlaySupport CoreUtils AirPlaySender
# The emulator ships with the package; the `fairplay` extra installs what it needs
# (unicorn, lief, capstone).
uv run --extra net --extra fairplay python examples/dump_frames.py --name "Test Screen" \
--fp-emu-dir fpdir --save-frame frame.png
Receiver(name="My Screen", legacy=True, fp_emu_dir="fpdir")
# fp_emu_python="<interpreter>" runs the emulator under a different Python
On the phone: Control Centre → Screen Mirroring → your receiver's name (PIN 3939 if
asked). After the emulator warms up, frame.png tracks the phone screen.
Scope
- Done: discovery, pairing (transient and PIN), screen-mirroring video (H.264 access units), FairPlay-gated SETUP and stream decryption, optional MFi proof at pair-setup.
- Not done: mirrored audio (dropped), HLS video casting, AirPlay 2 multi-room.
Development
uv run --extra net pytest
The scripts under tools/re/ run Ghidra against a firmware image you supply; their output is
never committed.
License
See LICENSE.
Metadata
Release files for pylibairplay 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylibairplay-0.1.1.tar.gz | 48.4 kB | With provenance | Details for pylibairplay-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylibairplay-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pylibairplay-0.1.1-py3-none-any.whl |
Total release size: 104.6 kB
Release files / pylibairplay-0.1.1.tar.gz
| Download URL | pylibairplay-0.1.1.tar.gz |
|---|---|
| Size | 48.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
daeb5c6efb6c52a1dcf24e49157a78767c89027c908a1cc842d50d0dadf17c3d
|
|
BLAKE2b-256 checksum How to use checksums |
4ee38b130077f59a7e5c63853acfbd93bcd2f770ecd6fe5e490964a988608412
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / pylibairplay-0.1.1-py3-none-any.whl
| Download URL | pylibairplay-0.1.1-py3-none-any.whl |
|---|---|
| Size | 56.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e911b8488efe7c239c0c598184bac4c53841458de127182ab5cccfcf2cb4ae1
|
|
BLAKE2b-256 checksum How to use checksums |
3740d0833f601d2bf914eddbd9a440c21129b9aa7b6852b5f28da086c185d05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for pylibairplay 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pylibairplay-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.