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 policy
Expected 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) has backup_codec_policy field
- ✅
BackupCodecPolicy enum 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
BackupCodecPolicy enum from livekit.protocol.models
- Extend
LocalParticipant.publish_track() with two new optional parameters:
backup_codec_policy: Optional[int] - Accepts BackupCodecPolicy enum values
backup_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
Description
The Python SDK is missing backup codec support that is available in the JavaScript SDK. The
BackupCodecPolicyenum exists at the protocol level, but the high-levelpublish_track()API doesn't expose it to developers.Current Behavior
Expected Behavior
JavaScript SDK Comparison
The JavaScript SDK already supports this feature:
Impact
Without backup codec support, Python developers cannot:
Investigation
I've confirmed that:
TrackInfo(protocol level) hasbackup_codec_policyfieldBackupCodecPolicyenum exists with values:PREFER_REGRESSION(0),SIMULCAST(1),REGRESSION(2)TrackPublishOptions(high-level API) doesn't expose these fields to developersProposed Solution
I've created a PR that adds this functionality: #510
The changes:
BackupCodecPolicyenum fromlivekit.protocol.modelsLocalParticipant.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")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
Related
backupCodecoption inTrackPublishOptions