Skip to main content

Voice, video, and stream transport extension for discord.py-self

Project description

discord-native-voice

A native voice extension for discord.py-self.

This package plugs into discord.py-self's normal voice connection flow and adds voice receive, video, and Go Live stream support. It is meant to feel like a drop-in replacement for the existing VoiceClient.

[!IMPORTANT] This project is still under active development and may have issues.

Currently, it is only compatible with discord.py-self. discord.py is not supported, but contributions towards changing this are welcome.

Key Features

  • Native voice send and receive
  • Video send and receive for all Discord video codecs: AV1, H265, H264, VP8, and VP9
  • Go Live stream creation, watching, sending, and receiving
  • Media sources for FFmpeg files, desktop capture, raw audio, and raw video
  • Media sinks for callbacks, queues, WAV output, FFmpeg output, and muxed audio/video recordings
  • Codec advertisement based on local FFmpeg support
  • RTX/NACK support for video packet recovery
  • Video simulcast support
  • End-to-end encryption support with DAVE
  • Compatible with nearly all existing voice sinks

Installing

Python 3.10 or higher is required.

Install discord.py-self first, then install this extension:

# Linux/macOS
python3 -m pip install -U discord.py-self <todo>

# Windows
py -3 -m pip install -U discord.py-self <todo>

Note that PyNaCl is not required when using this extension.

A Rust toolchain is required when building from source. FFmpeg is also recommended, since the built-in file, desktop, and recording helpers use it.

For development tools:

python3 -m pip install -U .[dev]

Quick Example

[!NOTE] In the future, discord.py-self will automatically prioritize this extension's voice implementation when installed.

Connect with the native voice client:

from discord.ext.native_voice import VoiceClient

voice = await channel.connect(cls=VoiceClient, self_video=True)

Play a media file with audio and video:

from discord.ext.native_voice import FFmpegMediaSource, VoiceClient

voice = await channel.connect(cls=VoiceClient, self_video=True)

source = FFmpegMediaSource.from_file(
    'clip.mp4',
    'H264',
    width=1280,
    height=720,
    fps=30,
    bitrate=4_000_000,
)

voice.play(source)

Receive media with a callback:

from discord.ext.native_voice import MediaPacket, VoiceClient

voice = await channel.connect(cls=VoiceClient)

def on_packet(packet: MediaPacket) -> None:
    print(packet.media_type, packet.codec, packet.user_id)

voice.listen(on_packet)

Go Live Streams

Streams use a separate StreamClient, created from an existing native voice connection.

from discord.ext.native_voice import FFmpegMediaSource, StreamClient, VoiceClient

voice = await channel.connect(cls=VoiceClient)
stream = await voice.create_stream(cls=StreamClient)

# Simplified example, reality is slightly more complicated
source = FFmpegMediaSource.from_desktop(
    'H264',
    width=1920,
    height=1080,
    fps=30,
    bitrate=6_000_000,
)

stream.play(source)

To watch another user's stream:

stream = voice.streams[0]
stream_client = await stream.watch(cls=StreamClient)

Configuration

Options that affect Discord's voice negotiation should be set before connecting. Use with_config() to create a configured client class:

from discord.ext.native_voice import VoiceClient

ConfiguredVoiceClient = VoiceClient.with_config(
    rtx=False,
    udp_qos=True,
    enable_debug_stats=True,
)

voice = await channel.connect(cls=ConfiguredVoiceClient, self_video=True)

Media Helpers

The extension includes source and sink helpers for common media tasks:

  • FFmpegMediaSource and FFmpegVideoSource for files, pipes, and desktop capture.
  • PCMMediaSource, AudioFrameSource, and VideoFrameSource for already produced audio or video.
  • QueueSink and AsyncQueueSink for application-managed receive loops.
  • WaveSink, MixedWaveSink, FFmpegSink, and FFmpegMuxSink for recording.
  • MultiSink, PerUserSink, and filter sinks for routing packets.

For advanced integrations, received media is exposed as MediaPacket objects with RTP metadata and parsed RTP extensions.

Docs

Docs are available at https://discord-native-voice.readthedocs.io/en/latest/index.html. Credits to discord.py for the theme.

Issues

For now, issues should be opened under this repository. Eventually, they will be migrated to the discord.py-self repository.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord_native_voice-0.1.1.tar.gz (126.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

discord_native_voice-0.1.1-cp310-abi3-win_arm64.whl (399.6 kB view details)

Uploaded CPython 3.10+Windows ARM64

discord_native_voice-0.1.1-cp310-abi3-win_amd64.whl (419.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

discord_native_voice-0.1.1-cp310-abi3-win32.whl (405.4 kB view details)

Uploaded CPython 3.10+Windows x86

discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl (630.1 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl (604.3 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

discord_native_voice-0.1.1-cp310-abi3-manylinux_2_31_armv7l.whl (542.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.31+ ARMv7l

discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl (553.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_i686.whl (595.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ i686

discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl (540.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

discord_native_voice-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (496.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

discord_native_voice-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl (512.8 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

discord_native_voice-0.1.1-cp310-abi3-android_24_x86_64.whl (558.2 kB view details)

Uploaded Android API level 24+ x86-64CPython 3.10+

discord_native_voice-0.1.1-cp310-abi3-android_24_arm64_v8a.whl (552.1 kB view details)

Uploaded Android API level 24+ ARM64 v8aCPython 3.10+

File details

Details for the file discord_native_voice-0.1.1.tar.gz.

File metadata

  • Download URL: discord_native_voice-0.1.1.tar.gz
  • Upload date:
  • Size: 126.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for discord_native_voice-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1581f29798b543d19845bd55efeee739df28f038d1656635088dff1d6dfe10b4
MD5 2a1bee6af3f09ffcd544a934f1896f49
BLAKE2b-256 b37ac95278781f76ad7033e70f124a8e5dc7b53cf68add7b82daa9095d8c65dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1.tar.gz:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 81e30eb9e7b8f71fdaea5d8800f444d8b67a8aad79136302e88c8b50d38ae31f
MD5 c34871559282e938ac88633b0a018f85
BLAKE2b-256 05b8c8f907f58672b075917283ef697dbef187089301dbf1862a489fe27c9e01

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-win_arm64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 95b435f52690ca031fff0cecf317ee13ccd75a7f57a9c7ffacf0fec0b2abe98e
MD5 e4b20f54c41d209ef691bc1f32a41f13
BLAKE2b-256 d9ac17f736177ce26197949144d66711ab49f25fc3e1f239a923ea0bbe0af96b

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-win_amd64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 4d9e977148c62f6624c3577a17c43be73f362b3ed698dd5954d08b451846ccfd
MD5 1c0999358e8d8b5d085d2aa45876408d
BLAKE2b-256 aae176b12d731eb1124cf6cdc8c02c85a6c127c7b4573c57aabc41d5d5734e7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-win32.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 41b8044904c3a60d85ed8b750b8a2e5b0ffce91cc5cb9d43fc854e188c68ff31
MD5 b4f6269b3a4c0136baed0d30c156f246
BLAKE2b-256 af9c60a3d1784c4aacb7feaf914c58d66bf7e55bf016bf0dfb3ffc03f317ccd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 21152886523787465a6cb12ee4af65217a53713a046c5f97325ccf038f255ac6
MD5 5d3942cf2bb72135f50802dac60b14a2
BLAKE2b-256 010d7774105f29e36c01345bba9eb2ac28caf8e4ae77590d99714215e0cf625b

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-manylinux_2_31_armv7l.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_31_armv7l.whl
Algorithm Hash digest
SHA256 c00d5218cd8d6a73790bdc920d0c3f4809ee289a2c38ea6e3623747321404059
MD5 b8791094e1a14a8d3069d7a370b181d9
BLAKE2b-256 8c4b3cd7c460ca42f8b0083a901672cf7f04d61d72f52a1e3844de863d93513d

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_31_armv7l.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 221e3952025ce52d09a44212a0904c540a241f109acd5621e39612ba12303aa0
MD5 b6161d742ec9e6e09f33bdf9acf9ab78
BLAKE2b-256 ad4e9f51087d500417f7f4f33ab5b72d9cad5c66ee20f23e4569dc4131f5f313

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_i686.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_i686.whl
Algorithm Hash digest
SHA256 a154e62fd902c77ba1adbdd92cd9c2391d8ad09827a8b9fe39d29d5813fea500
MD5 5ba369635d7c867b20235af1f9a52904
BLAKE2b-256 7133550d146a5292fb3dbe442fa855e3976a74d6aecd9c3aedafb7b30adbeb76

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_i686.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e2b2fbbf24ce6036231472f89155a55de16a18ab0068520437ff1e7a030775a6
MD5 fe26ba1d087f924fd980738d6ef390cb
BLAKE2b-256 998db43dbe0158d5828c8bc9176a832e281a964222a18842a30e68f22eaad4fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1cba18f1aef6f1d2be3e7907d7df685314993f13dc60d6943a8d5c73200e4df0
MD5 e3271990489a67f8bf43ac50cddced0c
BLAKE2b-256 22bb716aa8adfa97c11342d51bff786738ac75ffca6980793b261d82139dc6a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed3f39dda4c970a2d8652dd682036df630f6cfbe2b16af25b1cd28d2cb787b45
MD5 67c71a9b747553a9a5fcace1f03091d5
BLAKE2b-256 6a7314f109bd6f813fb3cd406aa5554c4644d80f93278313b8e9e18a474bf04b

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-android_24_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 ed302b6c124757a90e7017f54db9d8c80e5fa5cfb50e869fb33068b7d12c8cc6
MD5 828fe477471b88f812550412f4c53fcc
BLAKE2b-256 fa568920828ecd27073621f55ff3802069da2361b456f63f856ef77e4ef9e0ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-android_24_x86_64.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discord_native_voice-0.1.1-cp310-abi3-android_24_arm64_v8a.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.1-cp310-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 8faf9fc2ed21ba2155537459f4e6d42d96819f01bc30d2d6b3f47463f32fee6a
MD5 8a5aa3c33d97e5a88c20250c3bca1c9f
BLAKE2b-256 97482fe4cbe3280d76bbcb83fcfb6d4ed6c5d8833f11bb09bf7e00041fe6593a

See more details on using hashes here.

Provenance

The following attestation bundles were made for discord_native_voice-0.1.1-cp310-abi3-android_24_arm64_v8a.whl:

Publisher: publish.yml on dolfies/discord-native-voice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page