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.0.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.0-cp313-cp313-android_24_x86_64.whl (557.4 kB view details)

Uploaded Android API level 24+ x86-64CPython 3.13

discord_native_voice-0.1.0-cp313-cp313-android_24_arm64_v8a.whl (551.5 kB view details)

Uploaded Android API level 24+ ARM64 v8aCPython 3.13

discord_native_voice-0.1.0-cp311-cp311-win_amd64.whl (415.6 kB view details)

Uploaded CPython 3.11Windows x86-64

discord_native_voice-0.1.0-cp310-cp310-win_arm64.whl (399.0 kB view details)

Uploaded CPython 3.10Windows ARM64

discord_native_voice-0.1.0-cp310-cp310-win32.whl (404.8 kB view details)

Uploaded CPython 3.10Windows x86

discord_native_voice-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl (629.8 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

discord_native_voice-0.1.0-cp310-cp310-musllinux_1_2_aarch64.whl (603.9 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ ARM64

discord_native_voice-0.1.0-cp310-cp310-manylinux_2_31_armv7l.whl (542.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.31+ ARMv7l

discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (552.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_i686.whl (594.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ i686

discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_aarch64.whl (539.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

discord_native_voice-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (495.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

discord_native_voice-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl (512.2 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: discord_native_voice-0.1.0.tar.gz
  • Upload date:
  • Size: 126.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for discord_native_voice-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be740a4fe63ebeb08c9e851da8980eddb1483fe0e80131a061f68ee746631e96
MD5 64e7574ad42bd337b1a1e6c1ed1fb0f6
BLAKE2b-256 1acca3b54b6d64dc4ee944d33cb6383353266bc240fa5a194fda9d84bada033c

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp313-cp313-android_24_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp313-cp313-android_24_x86_64.whl
Algorithm Hash digest
SHA256 5e682698cd7a88a68da2c394b0544470b9c2a2d2efecdecaa7633a34e72aa052
MD5 6a1e357e8118961c04b2fe435e3fe0c2
BLAKE2b-256 f7a063fb511fd98cf436c218d1fa56fec7c49171113edc0f39e4714a3ca1e6e6

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp313-cp313-android_24_arm64_v8a.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp313-cp313-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 59e832e0338465640c8bbee06eac059c32b15627134c8bcc773a107466b41738
MD5 6fdc692078f244f90bc7dffabca25ab8
BLAKE2b-256 b05a5e2fb38146a5ba024fe318cc1b84e9994c4384563ba504e149d9c9f9861e

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fd14607c5bee3fdf89077991c385855d7a53fbeed3021cd0c96134b26a36874a
MD5 b2b54a8030efcdd034fc35b353020f10
BLAKE2b-256 0a692e44ff04af787f6c3bf8d65488c9370064ac3d891a2aed559939fc119943

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-win_arm64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-win_arm64.whl
Algorithm Hash digest
SHA256 c20a2de7ffaed0eb127d164b3d1c02550e6c38858fc170fc672c0c6cecaba4e2
MD5 c942a42a0e4e13f0c5e739cd9c16fd75
BLAKE2b-256 41dd21fcd775017c037f9fea189234f5496e0f0cd9378da73479b2e11a2d8dc1

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 bea354215726680fe7a68a75dc823eb1f60df64f3449731e6a228ca9fb8e0c37
MD5 7e67646eb51fbeaf655e5ddbf0eefe7c
BLAKE2b-256 eb0dc61e78f18c6092a439a340aeaf403c72a2986c10ba93b0ff76f649da688d

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e60c987c197c6bca14bc2fff5570055c3780d80b5262df76d0286d3ecab6560a
MD5 ccdc5dc34277c5982715ef6a28403940
BLAKE2b-256 0cf8d718a7d88941272fb857e3cee0097aeb5a550db04c73bb68d94397ab3f9e

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2afdc2f3913bdcc2d01718f83f9b07a243d7f6bb4f00e64099836dad9945a5ce
MD5 5b4b477a44d6555d81484d24d0a74bd7
BLAKE2b-256 8f4d6d7a7dfb61b755707fa0fa0834910a7b2aad38704ded27ba5d4a7b472794

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-manylinux_2_31_armv7l.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-manylinux_2_31_armv7l.whl
Algorithm Hash digest
SHA256 d94fc5ef75c668a75d915ce9c58141eb2dee993931e79f929436fcfb582c4fc7
MD5 608a8b7558b1a9dadb6d561be749331b
BLAKE2b-256 1fb0c1ba97e850e134370bb60a55a5801cc9bb50e71e658a11a3cccfd73b3886

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 356746c589f80ea5bc9914db74baac8acc2121ba0e4f3a4f74b4393f5460a66b
MD5 548f5ca997d863e029f7666f741c8554
BLAKE2b-256 c1c69944b7bd176e2c80f9b3fafd098e52f23cd88d99292cc95f3ee152f95ad1

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_i686.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_i686.whl
Algorithm Hash digest
SHA256 a3b2723bc90206760dd94100431541c0ad344f70a26134ad40b7b502f3b25faf
MD5 1f16183b0b3470263598e2934d86070a
BLAKE2b-256 f05a70b0fa39321767575c00881f9e0b3af4b6b5441a3c597b0e7be44fedcdc7

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5e95bff0deaaaf59e4a50d98e3ebafb45d5bd2765727ba7737db228aa4ce5d56
MD5 5aaa39cd4c22d74b36292a30273b739b
BLAKE2b-256 2603eae40620ab4b5f7bec2f168224f486c4cc96a356983f9ca348e33e1420f9

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 efd58507acc809f8783914627e2e461ac818d9ad717b9a08c4f11694eb724f9d
MD5 bfeff576797ea2538c87fa635080c6db
BLAKE2b-256 6e170fdc667ea686a4de27061f459c1eee9985a0af13d5def7d2574dc045208f

See more details on using hashes here.

File details

Details for the file discord_native_voice-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for discord_native_voice-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fdac86d146e6297d86c8b332f17cd42de09f88128eb92b4f2591aefd93b2a504
MD5 e0a08430d78f18011ee1a9f5623f94e7
BLAKE2b-256 63d5c38046620fada88e4d02a6c9c81ab6773ef0d333ad3162d58e2833b5ec5c

See more details on using hashes here.

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