-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
Description
The Python SDK is missing backup codec support that is available in the JavaScript SDK. The BackupCodecPolicy enum exists at the protocol level, but the high-level publish_track() API doesn't expose it to developers.
Current Behavior
# Python SDK - backup codec NOT supported
publication = await room.local_participant.publish_track(track, options)
# No way to specify backup codec or policyExpected Behavior
# Python SDK - should support backup codec like JS SDK
publication = await room.local_participant.publish_track(
track,
options,
backup_codec_policy=rtc.BackupCodecPolicy.PREFER_REGRESSION,
backup_codec="h264"
)JavaScript SDK Comparison
The JavaScript SDK already supports this feature:
await room.localParticipant.publishTrack(track, {
videoCodec: 'vp8',
backupCodec: { codec: 'h264' },
});Impact
Without backup codec support, Python developers cannot:
- Specify codec fallback behavior for better compatibility
- Handle cases where the primary codec isn't supported by all participants
- Match the functionality available in other SDKs
Investigation
I've confirmed that:
- ✅
TrackInfo(protocol level) hasbackup_codec_policyfield - ✅
BackupCodecPolicyenum exists with values:PREFER_REGRESSION(0),SIMULCAST(1),REGRESSION(2) - ❌
TrackPublishOptions(high-level API) doesn't expose these fields to developers
Proposed Solution
I've created a PR that adds this functionality: #510
The changes:
- Import and export
BackupCodecPolicyenum fromlivekit.protocol.models - Extend
LocalParticipant.publish_track()with two new optional parameters:backup_codec_policy: Optional[int]- Accepts BackupCodecPolicy enum valuesbackup_codec: Optional[str]- Accepts codec name (e.g., "vp8", "h264")
- Includes graceful fallback if FFI protocol doesn't support the fields
- Fully backward compatible
Request
Could the team please review PR #510 and consider merging it? This would bring the Python SDK to feature parity with the JavaScript SDK and enable codec fallback support for Python developers.
Happy to make any adjustments based on feedback!
Environment
- LiveKit Python SDK: 1.0.16
- Python: 3.11+
- Platform: All platforms
Related
- PR: Add Backup Codec Support to Python SDK #510
- Related to JavaScript SDK's
backupCodecoption inTrackPublishOptions
Metadata
Metadata
Assignees
Labels
No labels