Skip to main content

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylibairplay 0.1.0
File Size Uploaded Provenance Actions
pylibairplay-0.1.0.tar.gz 48.4 kB With provenance Details for pylibairplay-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylibairplay 0.1.0
File Interpreter ABI Platform Actions
pylibairplay-0.1.0-py3-none-any.whl Python 3 none any Details for pylibairplay-0.1.0-py3-none-any.whl

Total release size: 104.5 kB

Release files / pylibairplay-0.1.0.tar.gz

Download URL pylibairplay-0.1.0.tar.gz
Size 48.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6ff600d6d7eb6da015d5e0af228327009b110e1ab78acd2114d25b53d280df42
BLAKE2b-256 checksum
How to use checksums
55f011cc4cc6009579f9cffea2f6c5ec961a83b918eb4bdcae042da66379d6d2
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 log

Release files / pylibairplay-0.1.0-py3-none-any.whl

Download URL pylibairplay-0.1.0-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec0fc1971cfd2c7ae306ff6e22dafc4c5a370d6a55a00e3e6d282835054512b1
BLAKE2b-256 checksum
How to use checksums
b168af2b547187d9aecfe58529e77b30a818a180810d09298b2dd2bf58f2db7b
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 log

Security for pylibairplay 0.1.0

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.

Select from 2 files

Attestation for pylibairplay-0.1.0.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 log

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page