Metadata-Version: 2.4
Name: livekit
Version: 1.1.21
Summary: Python Real-time SDK for LiveKit
Author-email: LiveKit <support@livekit.io>
License-Expression: Apache-2.0
Project-URL: Documentation, https://docs.livekit.io
Project-URL: Website, https://livekit.io/
Project-URL: Source, https://github.com/livekit/python-sdks/
Keywords: webrtc,realtime,audio,video,livekit
Classifier: Intended Audience :: Developers
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9.0
Description-Content-Type: text/markdown
Requires-Dist: protobuf>=5
Requires-Dist: types-protobuf>=5
Requires-Dist: aiofiles>=24
Requires-Dist: numpy>=1.26

# LiveKit SDK for Python

Python SDK to integrate LiveKit's real-time video, audio, and data capabilities into your Python applications using WebRTC. Designed for use with [LiveKit Agents](https://github.com/livekit/agents) to build powerful voice AI apps.

See https://docs.livekit.io/ for more information.

## Publishing pre-encoded video

Use `EncodedVideoSource` when an upstream encoder already provides compressed
frames. The source uses the same native passthrough encoder as the Rust SDK;
Python does not decode or re-encode the video.

```python
from livekit import rtc

source = rtc.EncodedVideoSource(width=640, height=360)
track = rtc.LocalVideoTrack.create_video_track("camera", source)
await room.local_participant.publish_track(
    track,
    rtc.TrackPublishOptions(
        video_codec=rtc.VideoCodec.VP9,
        video_encoder=rtc.VideoEncoderBackend.ENCODER_BACKEND_PRE_ENCODED,
        simulcast=False,
    ),
)
# Supply each complete encoded frame at its playback time.
source.capture_frame(rtc.EncodedVideoFrame(
    data=encoded_vp9_frame,
    width=640,
    height=360,
    codec=rtc.VideoCodec.VP9,
    frame_type=rtc.EncodedFrameType.ENCODED_FRAME_KEY,
    timestamp_us=capture_timestamp_us,
))
feedback = source.take_feedback()
# Forward feedback.keyframe_requested and feedback.rate_control to your encoder.
# At shutdown, unpublish the track and release the source:
await room.local_participant.unpublish_track(track.sid)
await source.aclose()
```

Supported codecs are H.264, H.265, VP8, VP9 and AV1, subject to receiver support.
Submit complete access units (Annex B for H.264/H.265), not WebM/MP4 container
bytes or RTP packets. A container must first be demuxed; demuxing extracts
compressed frames and does not reconstruct pixels. The codec must match the
publication and stay fixed, and simulcast must be disabled.

The caller controls pacing and handles keyframe and bitrate feedback. In
particular, a prerecorded file cannot generate a new keyframe on demand for a
late subscriber or after packet loss. WebM's auxiliary alpha data is not part of
the VP9 color access unit and is not transported by this API.
